2023-03-06 18:25:30 +00:00
|
|
|
import { loader$ } from '@builder.io/qwik-city'
|
2023-03-07 15:45:52 +00:00
|
|
|
import { isAdminSymbol } from 'wildebeest/backend/src/activitypub/actors'
|
2023-03-06 18:25:30 +00:00
|
|
|
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]
|
2023-03-06 18:25:30 +00:00
|
|
|
|
|
|
|
if (!isAdmin) {
|
|
|
|
return html(401, getErrorHtml('You need to be an admin to view this page'))
|
|
|
|
}
|
|
|
|
})
|