Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 55s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 55s
This commit is contained in:
commit
8ee823a4d8
2 changed files with 34 additions and 2 deletions
|
|
@ -236,6 +236,38 @@ class CheckAuth {
|
|||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async checkRootDna(token: any, keycloakId: string) {
|
||||
const redisClient = await this.redis.createClient({
|
||||
host: process.env.REDIS_HOST,
|
||||
port: process.env.REDIS_PORT,
|
||||
});
|
||||
const getAsync = promisify(redisClient.get).bind(redisClient);
|
||||
try {
|
||||
let reply = await getAsync("org_" + keycloakId);
|
||||
if (reply != null) {
|
||||
reply = JSON.parse(reply);
|
||||
} else {
|
||||
if (!keycloakId) throw new Error("No KeycloakId provided");
|
||||
const x = await new CallAPI().GetData(
|
||||
{
|
||||
headers: { authorization: token },
|
||||
},
|
||||
`/org/dotnet/user-logs/${keycloakId}`,
|
||||
false,
|
||||
);
|
||||
|
||||
const data = {
|
||||
rootDnaId: x.rootDnaId,
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error calling API:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
public async PermissionCreate(req: RequestWithUser, system: string) {
|
||||
return await this.Permission(req, system, "CREATE");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
|||
|
||||
try {
|
||||
rootId = token
|
||||
? await new permission().checkOrg(token, req.app.locals.logData.userId)
|
||||
? await new permission().checkRootDna(token, req.app.locals.logData.userId)
|
||||
: null;
|
||||
} catch (err) {
|
||||
console.warn("Error fetching rootId:", err);
|
||||
|
|
@ -59,7 +59,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
|||
const obj = {
|
||||
logType: res.statusCode >= 500 ? "error" : res.statusCode >= 400 ? "warning" : "info",
|
||||
ip: req.ip,
|
||||
rootId: rootId?.orgRootId ?? null,
|
||||
rootId: rootId?.rootDnaId ?? null,
|
||||
systemName: "salary",
|
||||
startTimeStamp: timestamp,
|
||||
endTimeStamp: new Date().toISOString(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue