refactor: change condition order
This commit is contained in:
parent
f89dfcad37
commit
32127ae804
1 changed files with 1 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ export async function keycloakAuth(request: Express.Request, roles?: string[]) {
|
|||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(roles) && roles.length > 0 && Array.isArray(payload.roles)) {
|
||||
if (Array.isArray(payload.roles) && Array.isArray(roles) && roles.length > 0) {
|
||||
if (!roles.some((a: string) => payload.roles.includes(a))) {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, "คุณไม่มีสิทธิในการเข้าถึงข้อมูลดังกล่าว");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue