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

View File

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

View File

@ -1,39 +1,40 @@
{ {
"app": { "app": {
"name": "Service User", "name": "Service User",
"description": "Purpose of this service is to provide authorization, roles, user activity and etc", "description": "Purpose of this service is to provide authorization, roles, user activity and etc",
"version": "1.0.0", "version": "1.0.0",
"env": "Staging" "env": "Staging"
}, },
"server": { "server": {
"port": "4001", "port": "4001",
"host": "0.0.0.0", "host": "0.0.0.0",
"host_swagger": "https://brilianapps.shiblysolution.id/test/u/", "host_swagger": "https://brilianapps.shiblysolution.id/test/u/",
"max_body": "50mb", "max_body": "50mb",
"max_upload": 104857600, "max_upload": 104857600,
"morgan": "combined", "morgan": "combined",
"cors": "*", "cors": "*",
"ssl": { "ssl": {
"enable": false, "enable": false,
"cert": "", "cert": "",
"key": "" "key": ""
} }
}, },
"database": { "database": {
"engine": "postgres", "engine": "postgres",
"host": "172.16.11.202", "host": "172.16.11.202",
"port": "5432", "port": "5432",
"username": "bri_staging", "username": "bri_staging",
"password": "fK*#o>1W2&6f", "password": "fK*#o>1W2&6f",
"database": "bri_erp_staging", "database": "bri_erp_staging",
"logging": true "logging": true
}, },
"auth": { "auth": {
"refresh_token_lifetime_day": 1, "refresh_token_lifetime_day": 1,
"access_token_lifetime": 86400, "access_token_lifetime": 86400,
"reset_password_url": "https://brilianapps.shiblysolution.id/ukln/auth/reset-password/" "reset_password_url": "https://brilianapps.shiblysolution.id/ukln/auth/reset-password/"
}, },
"service": { "service": {
"notification": "http://127.0.0.1:4008/" "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'); return ReturnHelper.errorResponse(res, 403, 403, Language.lang.failed_access + ', you don\'t have any roles in this application');
} else { } else {
// const userRole = await userRoleRepository.findOneBy({ id: role_id }) // 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'); var privateKey = fs.readFileSync('src/helpers/key/private.key');
@ -107,7 +127,7 @@ export class AuthController {
delete user.password; delete user.password;
const data = { const data = {
user, user: { ...user, ...hrms },
role_name: roles.name, role_name: roles.name,
roles_list: await AuthController.getListRole(roles.roles), roles_list: await AuthController.getListRole(roles.roles),
token: { token: {