wildebeest/frontend/src/utils/adminLoader.ts

13 wiersze
488 B
TypeScript
Czysty Zwykły widok Historia

import { loader$ } from '@builder.io/qwik-city'
2023-03-07 15:45:52 +00:00
import { isAdminSymbol } from 'wildebeest/backend/src/activitypub/actors'
import { getErrorHtml } from './getErrorHtml/getErrorHtml'
2023-03-07 15:45:52 +00:00
export const adminLoader = loader$(async ({ platform, html }) => {
const isAuthorized = platform.data.connectedActor !== null
const isAdmin = isAuthorized && platform.data.connectedActor[isAdminSymbol]
if (!isAdmin) {
return html(401, getErrorHtml('You need to be an admin to view this page'))
}
})