Fix permission authentication-only not returning true

This commit is contained in:
sianida26 2024-05-23 23:35:09 +07:00
parent a55092d798
commit e5b27b77c9

View File

@ -27,11 +27,13 @@ const checkPermission = (...permissions: PermissionCode[]) =>
const hasPermission = currentUser.permissions.some((p) =>
permissions.includes(p)
);
if (hasPermission) {
if (hasPermission || permissions.includes("authenticated-only")) {
await next();
} else {
unauthorized();
}
} else if (permissions.includes("guest-only")) {
await next();
} else {
// No current user found, trigger unauthorized error
unauthorized();