แก้ throw error

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2024-12-18 18:59:35 +07:00
parent 3e576ef937
commit fec8c4d6f4
2 changed files with 50 additions and 41 deletions

View file

@ -183,19 +183,18 @@ class CheckAuth {
return false;
});
}
public async checkOrg(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);
let reply = await getAsync("org_" + keycloakId);
if (reply != null) {
reply = JSON.parse(reply);
} else {
try {
if (!keycloakId) throw "Error calling API No KeycloakId";
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 },
@ -213,10 +212,10 @@ class CheckAuth {
};
return data;
} catch (error) {
console.error("Error calling API:", error);
throw error;
}
} catch (error) {
console.error("Error calling API:", error);
throw error;
}
}
public async PermissionCreate(req: RequestWithUser, system: string) {