mirror of
https://github.com/umami-software/umami.git
synced 2026-02-11 08:07:12 +01:00
Add permission checks.
This commit is contained in:
parent
51e2331315
commit
78225691df
20 changed files with 225 additions and 333 deletions
|
|
@ -1,10 +1,11 @@
|
|||
import { ok, unauthorized, methodNotAllowed, badRequest, hashPassword } from 'next-basics';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import { createUser, getUser, getUsers } from 'queries';
|
||||
import { NextApiRequestQueryBody } from 'interface/api/nextApi';
|
||||
import { checkPermission } from 'lib/auth';
|
||||
import { UmamiApi } from 'lib/constants';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { User } from 'interface/api/models';
|
||||
import { badRequest, hashPassword, methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { createUser, getUser, getUsers, User } from 'queries';
|
||||
|
||||
export interface UsersRequestBody {
|
||||
username: string;
|
||||
|
|
@ -18,11 +19,7 @@ export default async (
|
|||
) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const {
|
||||
user: { isAdmin },
|
||||
} = req.auth;
|
||||
|
||||
if (!isAdmin) {
|
||||
if (!(await checkPermission(req, UmamiApi.Permission.Admin))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue