mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-01 20:39:44 +01:00
Update team/website permission check.
This commit is contained in:
parent
c5345b01bb
commit
f794b5674b
@ -4,7 +4,7 @@ import debug from 'debug';
|
|||||||
import { PERMISSIONS, ROLE_PERMISSIONS, SHARE_TOKEN_HEADER } from 'lib/constants';
|
import { PERMISSIONS, ROLE_PERMISSIONS, SHARE_TOKEN_HEADER } from 'lib/constants';
|
||||||
import { secret } from 'lib/crypto';
|
import { secret } from 'lib/crypto';
|
||||||
import { createSecureToken, ensureArray, getRandomChars, parseToken } from 'next-basics';
|
import { createSecureToken, ensureArray, getRandomChars, parseToken } from 'next-basics';
|
||||||
import { findTeamWebsiteByUserId, getTeamUser, getTeamWebsite, getWebsitesByUserId } from 'queries';
|
import { findTeamWebsiteByUserId, getTeamUser, getTeamWebsite } from 'queries';
|
||||||
import { loadWebsite } from './load';
|
import { loadWebsite } from './load';
|
||||||
import { Auth } from './types';
|
import { Auth } from './types';
|
||||||
|
|
||||||
@ -60,11 +60,11 @@ export async function canViewWebsite({ user, shareToken }: Auth, websiteId: stri
|
|||||||
|
|
||||||
export async function canCreateWebsite({ user, grant }: Auth) {
|
export async function canCreateWebsite({ user, grant }: Auth) {
|
||||||
if (cloudMode) {
|
if (cloudMode) {
|
||||||
if (grant.find(a => a === PERMISSIONS.websiteCreate)) {
|
if (grant?.find(a => a === PERMISSIONS.websiteCreate)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (await getWebsitesByUserId(user.id)).count < Number(process.env.WEBSITE_LIMIT);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.isAdmin) {
|
if (user.isAdmin) {
|
||||||
@ -120,7 +120,7 @@ export async function canDeleteReport(auth: Auth, report: Report) {
|
|||||||
|
|
||||||
export async function canCreateTeam({ user, grant }: Auth) {
|
export async function canCreateTeam({ user, grant }: Auth) {
|
||||||
if (cloudMode) {
|
if (cloudMode) {
|
||||||
if (grant.find(a => a === PERMISSIONS.teamCreate)) {
|
if (grant?.find(a => a === PERMISSIONS.teamCreate)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user