mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
30 lines
614 B
JavaScript
30 lines
614 B
JavaScript
import { getAccountById, deleteAccount } from 'queries';
|
|
import { useAuth } from 'lib/middleware';
|
|
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
|
|
|
export default async (req, res) => {
|
|
await useAuth(req, res);
|
|
|
|
const { is_admin } = req.auth;
|
|
const { id } = req.query;
|
|
const user_id = +id;
|
|
|
|
if (!is_admin) {
|
|
return unauthorized(res);
|
|
}
|
|
|
|
if (req.method === 'GET') {
|
|
const account = await getAccountById(user_id);
|
|
|
|
return ok(res, account);
|
|
}
|
|
|
|
if (req.method === 'DELETE') {
|
|
await deleteAccount(user_id);
|
|
|
|
return ok(res);
|
|
}
|
|
|
|
return methodNotAllowed(res);
|
|
};
|