mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 17:15:37 +01:00
Refactor database queries.
This commit is contained in:
parent
a248f35db2
commit
f4ca353b5c
24 changed files with 371 additions and 329 deletions
21
pages/api/accounts.js
Normal file
21
pages/api/accounts.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { getAccounts } from 'lib/queries';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { ok, unauthorized, methodNotAllowed } from 'lib/response';
|
||||
|
||||
export default async (req, res) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { is_admin: current_user_is_admin } = req.auth;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (current_user_is_admin) {
|
||||
const accounts = await getAccounts();
|
||||
|
||||
return ok(res, accounts);
|
||||
}
|
||||
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
return methodNotAllowed(res);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue