adding hrms api on login

This commit is contained in:
fro1991
2025-02-13 22:21:00 +07:00
parent bf1f906f28
commit ca809a8642
4 changed files with 135 additions and 112 deletions

View File

@ -1,39 +1,40 @@
{
"app": {
"name": "Service Users",
"description": "Purpose of this service is to provide authorization, roles, user activity and etc",
"version": "1.0.0",
"env": "Development"
},
"server": {
"port": "4001",
"host": "0.0.0.0",
"host_swagger": "http://127.0.0.1:4001",
"max_body": "50mb",
"max_upload": 104857600,
"morgan": "combined",
"cors": "*",
"ssl": {
"enable": false,
"cert": "",
"key": ""
}
},
"database": {
"engine": "postgres",
"host": "127.0.0.1",
"port": "5432",
"username": "postgres",
"password": "123",
"database": "bri_erp",
"logging": true
},
"auth": {
"refresh_token_lifetime_day": 30,
"access_token_lifetime": 86400,
"reset_password_url": "https://bri-dev.shiblysolution.id/auth/reset-password/"
},
"service": {
"notification": "http://127.0.0.1:4008/"
}
"app": {
"name": "Service Users",
"description": "Purpose of this service is to provide authorization, roles, user activity and etc",
"version": "1.0.0",
"env": "Development"
},
"server": {
"port": "4001",
"host": "0.0.0.0",
"host_swagger": "http://127.0.0.1:4001",
"max_body": "50mb",
"max_upload": 104857600,
"morgan": "combined",
"cors": "*",
"ssl": {
"enable": false,
"cert": "",
"key": ""
}
},
"database": {
"engine": "postgres",
"host": "127.0.0.1",
"port": "5432",
"username": "postgres",
"password": "123",
"database": "bri_erp",
"logging": true
},
"auth": {
"refresh_token_lifetime_day": 30,
"access_token_lifetime": 86400,
"reset_password_url": "https://bri-dev.shiblysolution.id/auth/reset-password/"
},
"service": {
"notification": "http://127.0.0.1:4008/",
"hrms": "https://brilianapps.shiblysolution.id/hrms/"
}
}

View File

@ -1,39 +1,40 @@
{
"app": {
"name": "Service User",
"description": "Purpose of this service is to provide authorization, roles, user activity and etc",
"version": "1.0.0",
"env": "Production"
},
"server": {
"port": "4001",
"host": "0.0.0.0",
"host_swagger": "https://brilianapps.britimorleste.tl/test/u",
"max_body": "50mb",
"max_upload": 104857600,
"morgan": "combined",
"cors": "*",
"ssl": {
"enable": false,
"cert": "",
"key": ""
}
},
"database": {
"engine": "postgres",
"host": "172.16.11.202",
"port": "5432",
"username": "bri_production",
"password": "44jTPj54%6<£",
"database": "bri_erp_production",
"logging": false
},
"auth": {
"refresh_token_lifetime_day": 30,
"access_token_lifetime": 86400,
"reset_password_url": "https://brilianapps.britimorleste.tl/ukln/auth/reset-password/"
},
"service": {
"notification": "http://127.0.0.1:4008/"
}
"app": {
"name": "Service User",
"description": "Purpose of this service is to provide authorization, roles, user activity and etc",
"version": "1.0.0",
"env": "Production"
},
"server": {
"port": "4001",
"host": "0.0.0.0",
"host_swagger": "https://brilianapps.britimorleste.tl/test/u",
"max_body": "50mb",
"max_upload": 104857600,
"morgan": "combined",
"cors": "*",
"ssl": {
"enable": false,
"cert": "",
"key": ""
}
},
"database": {
"engine": "postgres",
"host": "172.16.11.202",
"port": "5432",
"username": "bri_production",
"password": "44jTPj54%6<£",
"database": "bri_erp_production",
"logging": false
},
"auth": {
"refresh_token_lifetime_day": 30,
"access_token_lifetime": 86400,
"reset_password_url": "https://brilianapps.britimorleste.tl/ukln/auth/reset-password/"
},
"service": {
"notification": "http://127.0.0.1:4008/",
"hrms": "http://127.0.0.1:80/"
}
}

View File

@ -1,39 +1,40 @@
{
"app": {
"name": "Service User",
"description": "Purpose of this service is to provide authorization, roles, user activity and etc",
"version": "1.0.0",
"env": "Staging"
},
"server": {
"port": "4001",
"host": "0.0.0.0",
"host_swagger": "https://brilianapps.shiblysolution.id/test/u/",
"max_body": "50mb",
"max_upload": 104857600,
"morgan": "combined",
"cors": "*",
"ssl": {
"enable": false,
"cert": "",
"key": ""
}
},
"database": {
"engine": "postgres",
"host": "172.16.11.202",
"port": "5432",
"username": "bri_staging",
"password": "fK*#o>1W2&6f",
"database": "bri_erp_staging",
"logging": true
},
"auth": {
"refresh_token_lifetime_day": 1,
"access_token_lifetime": 86400,
"reset_password_url": "https://brilianapps.shiblysolution.id/ukln/auth/reset-password/"
},
"service": {
"notification": "http://127.0.0.1:4008/"
}
"app": {
"name": "Service User",
"description": "Purpose of this service is to provide authorization, roles, user activity and etc",
"version": "1.0.0",
"env": "Staging"
},
"server": {
"port": "4001",
"host": "0.0.0.0",
"host_swagger": "https://brilianapps.shiblysolution.id/test/u/",
"max_body": "50mb",
"max_upload": 104857600,
"morgan": "combined",
"cors": "*",
"ssl": {
"enable": false,
"cert": "",
"key": ""
}
},
"database": {
"engine": "postgres",
"host": "172.16.11.202",
"port": "5432",
"username": "bri_staging",
"password": "fK*#o>1W2&6f",
"database": "bri_erp_staging",
"logging": true
},
"auth": {
"refresh_token_lifetime_day": 1,
"access_token_lifetime": 86400,
"reset_password_url": "https://brilianapps.shiblysolution.id/ukln/auth/reset-password/"
},
"service": {
"notification": "http://127.0.0.1:4008/",
"hrms": "http://127.0.0.1:80/"
}
}

View File

@ -86,6 +86,26 @@ export class AuthController {
return ReturnHelper.errorResponse(res, 403, 403, Language.lang.failed_access + ', you don\'t have any roles in this application');
} else {
// const userRole = await userRoleRepository.findOneBy({ id: role_id })
var hrms = {
department_id: null,
department_name: null,
level_id: null,
level_name: null
}
if (user.nik) {
const url = config.get("service.hrms") + "api/get-employee?nik=" + user.nik;
const { data: dataHrms } = await axios.get(url);
if (dataHrms && dataHrms.status && dataHrms.data.count == 1) {
hrms = {
department_id: dataHrms.data.list[0].idxdept,
department_name: dataHrms.data.list[0].departement,
level_id: dataHrms.data.list[0].idxlevel,
level_name: dataHrms.data.list[0].level
}
}
}
var privateKey = fs.readFileSync('src/helpers/key/private.key');
@ -107,7 +127,7 @@ export class AuthController {
delete user.password;
const data = {
user,
user: { ...user, ...hrms },
role_name: roles.name,
roles_list: await AuthController.getListRole(roles.roles),
token: {