This commit is contained in:
Jose Conde
2024-07-12 16:27:52 +02:00
parent ca0f1466c2
commit 5f117667a4
29 changed files with 823 additions and 407 deletions

View File

@ -124,14 +124,14 @@ export class AuthController extends BaseController {
return false;
}
const tokenFromDb = await new ApiTokenMongoManager().getById(token._id.toString());
const tokenFromDb: Token = await new ApiTokenMongoManager().getById(token._id.toString()) as Token;
if (!tokenFromDb) {
return false;
}
const { roles } = tokenFromDb;
const validRoles = rolesToCheck.filter((r: string) => roles.includes(r));
const validRoles = rolesToCheck.filter((r: string) => roles?.includes(r) || false);
return validRoles.length === rolesToCheck.length;
}