auth) addressing issues with detecting admins
Some checks failed
PR Checks / lint-test-and-docker-build (pull_request) Failing after 1m3s
Some checks failed
PR Checks / lint-test-and-docker-build (pull_request) Failing after 1m3s
This commit is contained in:
@@ -4,12 +4,12 @@ import { requireAdmin } from '$lib/server/admin/auth.js';
|
||||
import { deleteUser, listUsers, updateUser } from '$lib/server/users.js';
|
||||
|
||||
export const GET: RequestHandler = async (event) => {
|
||||
requireAdmin((await event.locals.auth())?.user?.id);
|
||||
requireAdmin((await event.locals.auth())?.user);
|
||||
return json(listUsers());
|
||||
};
|
||||
|
||||
export const PATCH: RequestHandler = async (event) => {
|
||||
requireAdmin((await event.locals.auth())?.user?.id);
|
||||
requireAdmin((await event.locals.auth())?.user);
|
||||
const body = await event.request.json();
|
||||
const { id, username, full_name, email } = body as {
|
||||
id?: string;
|
||||
@@ -25,7 +25,7 @@ export const PATCH: RequestHandler = async (event) => {
|
||||
};
|
||||
|
||||
export const DELETE: RequestHandler = async (event) => {
|
||||
requireAdmin((await event.locals.auth())?.user?.id);
|
||||
requireAdmin((await event.locals.auth())?.user);
|
||||
const id = event.url.searchParams.get('id')?.trim();
|
||||
if (!id) return json({ error: 'id required' }, { status: 400 });
|
||||
deleteUser(id);
|
||||
|
||||
Reference in New Issue
Block a user