mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Added report context. Removed report store.
This commit is contained in:
parent
bc37f5124e
commit
bfb52eb678
31 changed files with 372 additions and 273 deletions
12
lib/auth.ts
12
lib/auth.ts
|
|
@ -1,4 +1,4 @@
|
|||
import { UserReport } from '@prisma/client';
|
||||
import { Report } from '@prisma/client';
|
||||
import redis from '@umami/redis-client';
|
||||
import debug from 'debug';
|
||||
import { PERMISSIONS, ROLE_PERMISSIONS, SHARE_TOKEN_HEADER } from 'lib/constants';
|
||||
|
|
@ -135,28 +135,28 @@ export async function canDeleteWebsite({ user }: Auth, websiteId: string) {
|
|||
return false;
|
||||
}
|
||||
|
||||
export async function canViewUserReport(auth: Auth, userReport: UserReport) {
|
||||
export async function canViewReport(auth: Auth, report: Report) {
|
||||
if (auth.user.isAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((auth.user.id = userReport.userId)) {
|
||||
if ((auth.user.id = report.userId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (await canViewWebsite(auth, userReport.websiteId)) {
|
||||
if (await canViewWebsite(auth, report.websiteId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function canUpdateUserReport(auth: Auth, userReport: UserReport) {
|
||||
export async function canUpdateReport(auth: Auth, report: Report) {
|
||||
if (auth.user.isAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((auth.user.id = userReport.userId)) {
|
||||
if ((auth.user.id = report.userId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue