Fix permission authentication-only not returning true
This commit is contained in:
parent
a55092d798
commit
e5b27b77c9
|
|
@ -27,11 +27,13 @@ const checkPermission = (...permissions: PermissionCode[]) =>
|
||||||
const hasPermission = currentUser.permissions.some((p) =>
|
const hasPermission = currentUser.permissions.some((p) =>
|
||||||
permissions.includes(p)
|
permissions.includes(p)
|
||||||
);
|
);
|
||||||
if (hasPermission) {
|
if (hasPermission || permissions.includes("authenticated-only")) {
|
||||||
await next();
|
await next();
|
||||||
} else {
|
} else {
|
||||||
unauthorized();
|
unauthorized();
|
||||||
}
|
}
|
||||||
|
} else if (permissions.includes("guest-only")) {
|
||||||
|
await next();
|
||||||
} else {
|
} else {
|
||||||
// No current user found, trigger unauthorized error
|
// No current user found, trigger unauthorized error
|
||||||
unauthorized();
|
unauthorized();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user