mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(api): ✨ Overhaul Role API, add ability to edit roles and assign/unassign them from any user
This commit is contained in:
parent
7431c1e21d
commit
49c53de99e
10 changed files with 926 additions and 153 deletions
22
utils/api.ts
22
utils/api.ts
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue