reworked
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user