mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 07:07:17 +01:00
Pixel/links development. New validations folder. More refactoring.
This commit is contained in:
parent
88639dfe83
commit
247e14646b
136 changed files with 1395 additions and 516 deletions
27
src/validations/report.ts
Normal file
27
src/validations/report.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { Auth } from '@/lib/types';
|
||||
import { Report } from '@prisma/client';
|
||||
import { canViewWebsite } from './website';
|
||||
|
||||
export async function canViewReport(auth: Auth, report: Report) {
|
||||
if (auth.user.isAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (auth.user.id == report.userId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !!(await canViewWebsite(auth, report.websiteId));
|
||||
}
|
||||
|
||||
export async function canUpdateReport({ user }: Auth, report: Report) {
|
||||
if (user.isAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return user.id == report.userId;
|
||||
}
|
||||
|
||||
export async function canDeleteReport(auth: Auth, report: Report) {
|
||||
return canUpdateReport(auth, report);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue