feat(api): Overhaul Role API, add ability to edit roles and assign/unassign them from any user

This commit is contained in:
Jesse Wierzbinski 2024-11-26 15:27:39 +01:00
parent 7431c1e21d
commit 49c53de99e
No known key found for this signature in database
10 changed files with 926 additions and 153 deletions

View file

@ -314,6 +314,17 @@ export const auth = (
// Only exists for type casting, as otherwise weird errors happen with Hono
const fakeResponse = context.json({});
// Authentication check
const authCheck = checkRouteNeedsAuth(auth, authData, context) as
| typeof fakeResponse
| AuthData;
if (authCheck instanceof Response) {
return authCheck;
}
context.set("auth", authCheck);
// Permissions check
if (permissionData) {
const permissionCheck = checkPermissions(
@ -326,6 +337,7 @@ export const auth = (
}
}
// Challenge check
if (challengeData && config.validation.challenges.enabled) {
const challengeCheck = await checkRouteNeedsChallenge(
challengeData,
@ -336,16 +348,6 @@ export const auth = (
}
}
const authCheck = checkRouteNeedsAuth(auth, authData, context) as
| typeof fakeResponse
| AuthData;
if (authCheck instanceof Response) {
return authCheck;
}
context.set("auth", authCheck);
await next();
});