Ausweis und weitere Änderungen
This commit is contained in:
@@ -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."
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user