add checkRootDna

This commit is contained in:
Adisak 2026-01-28 18:04:22 +07:00
parent d8d2794e3c
commit 02f06486ed
2 changed files with 36 additions and 2 deletions

View file

@ -236,6 +236,40 @@ 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");
}