mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Allow user to change admin username.
This commit is contained in:
parent
e31181c676
commit
faf6438852
5 changed files with 21 additions and 14 deletions
21
pages/api/accounts/index.js
Normal file
21
pages/api/accounts/index.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 } = req.auth;
|
||||
|
||||
if (!is_admin) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const accounts = await getAccounts();
|
||||
|
||||
return ok(res, accounts);
|
||||
}
|
||||
|
||||
return methodNotAllowed(res);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue