mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 05:37:20 +01:00
Updated roles and permissions logic.
This commit is contained in:
parent
4eb3140e43
commit
b57ecf33e6
63 changed files with 432 additions and 546 deletions
|
|
@ -6,6 +6,7 @@ import { findSession } from 'lib/session';
|
|||
import { getAuthToken, parseShareToken } from 'lib/auth';
|
||||
import { secret } from 'lib/crypto';
|
||||
import redis from 'lib/redis';
|
||||
import { ROLES } from 'lib/constants';
|
||||
import { getUser } from '../queries';
|
||||
|
||||
const log = debug('umami:middleware');
|
||||
|
|
@ -45,6 +46,10 @@ export const useAuth = createMiddleware(async (req, res, next) => {
|
|||
return unauthorized(res);
|
||||
}
|
||||
|
||||
if (user) {
|
||||
user.isAdmin = user.role === ROLES.admin;
|
||||
}
|
||||
|
||||
req.auth = { user, token, shareToken, key };
|
||||
next();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue