mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(server): upload config (#3148)
This commit is contained in:
parent
8349a28ed8
commit
398bd04ffd
23 changed files with 473 additions and 624 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { BadRequestException } from '@nestjs/common';
|
||||
import { BadRequestException, UnauthorizedException } from '@nestjs/common';
|
||||
import { AuthUserDto } from '../auth';
|
||||
import { IAccessRepository } from './access.repository';
|
||||
|
||||
|
|
@ -25,6 +25,13 @@ export enum Permission {
|
|||
export class AccessCore {
|
||||
constructor(private repository: IAccessRepository) {}
|
||||
|
||||
requireUploadAccess(authUser: AuthUserDto | null): AuthUserDto {
|
||||
if (!authUser || (authUser.isPublicUser && !authUser.isAllowUpload)) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
return authUser;
|
||||
}
|
||||
|
||||
async requirePermission(authUser: AuthUserDto, permission: Permission, ids: string[] | string) {
|
||||
const hasAccess = await this.hasPermission(authUser, permission, ids);
|
||||
if (!hasAccess) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue