Ausweis und weitere Änderungen

This commit is contained in:
Moritz Utcke
2025-02-18 18:17:02 +11:00
parent 8486421f12
commit c8ba17fab3
38 changed files with 1771 additions and 330 deletions

View File

@@ -91,4 +91,20 @@ export async function maybeAuthorizationMiddleware(input: any, ctx: TypesafeAPIC
export const authorizationHeaders = {
Authorization: z.string()
}
export async function adminMiddleware(input: any, ctx: TypesafeAPIContextWithRequest<any>) {
try {
const user = await authorizationMiddleware(input, ctx)
if (user.rolle === "ADMIN") {
return user
}
} catch(e) {
}
throw new APIError({
code: "FORBIDDEN",
"message": "Diese Route ist für Admins vorbehalten."
})
}