mirror of
https://github.com/immich-app/immich.git
synced 2025-12-17 17:23:20 +03:00
refactor(server): auth dto (#5593)
* refactor: AuthUserDto => AuthDto * refactor: reorganize auth-dto * refactor: AuthUser() => Auth()
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
AuthUserDto,
|
||||
AuthDto,
|
||||
CreateUserDto as CreateDto,
|
||||
CreateProfileImageDto,
|
||||
CreateProfileImageResponseDto,
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger';
|
||||
import { AdminRoute, AuthUser, Authenticated } from '../app.guard';
|
||||
import { AdminRoute, Auth, Authenticated } from '../app.guard';
|
||||
import { UseValidation, asStreamableFile } from '../app.utils';
|
||||
import { FileUploadInterceptor, Route } from '../interceptors';
|
||||
import { UUIDParamDto } from './dto/uuid-param.dto';
|
||||
@@ -36,8 +36,8 @@ export class UserController {
|
||||
constructor(private service: UserService) {}
|
||||
|
||||
@Get()
|
||||
getAllUsers(@AuthUser() authUser: AuthUserDto, @Query('isAll') isAll: boolean): Promise<UserResponseDto[]> {
|
||||
return this.service.getAll(authUser, isAll);
|
||||
getAllUsers(@Auth() auth: AuthDto, @Query('isAll') isAll: boolean): Promise<UserResponseDto[]> {
|
||||
return this.service.getAll(auth, isAll);
|
||||
}
|
||||
|
||||
@Get('info/:id')
|
||||
@@ -46,8 +46,8 @@ export class UserController {
|
||||
}
|
||||
|
||||
@Get('me')
|
||||
getMyUserInfo(@AuthUser() authUser: AuthUserDto): Promise<UserResponseDto> {
|
||||
return this.service.getMe(authUser);
|
||||
getMyUserInfo(@Auth() auth: AuthDto): Promise<UserResponseDto> {
|
||||
return this.service.getMe(auth);
|
||||
}
|
||||
|
||||
@AdminRoute()
|
||||
@@ -58,26 +58,26 @@ export class UserController {
|
||||
|
||||
@Delete('profile-image')
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
deleteProfileImage(@AuthUser() authUser: AuthUserDto): Promise<void> {
|
||||
return this.service.deleteProfileImage(authUser);
|
||||
deleteProfileImage(@Auth() auth: AuthDto): Promise<void> {
|
||||
return this.service.deleteProfileImage(auth);
|
||||
}
|
||||
|
||||
@AdminRoute()
|
||||
@Delete(':id')
|
||||
deleteUser(@AuthUser() authUser: AuthUserDto, @Param() { id }: UUIDParamDto): Promise<UserResponseDto> {
|
||||
return this.service.delete(authUser, id);
|
||||
deleteUser(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<UserResponseDto> {
|
||||
return this.service.delete(auth, id);
|
||||
}
|
||||
|
||||
@AdminRoute()
|
||||
@Post(':id/restore')
|
||||
restoreUser(@AuthUser() authUser: AuthUserDto, @Param() { id }: UUIDParamDto): Promise<UserResponseDto> {
|
||||
return this.service.restore(authUser, id);
|
||||
restoreUser(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<UserResponseDto> {
|
||||
return this.service.restore(auth, id);
|
||||
}
|
||||
|
||||
// TODO: replace with @Put(':id')
|
||||
@Put()
|
||||
updateUser(@AuthUser() authUser: AuthUserDto, @Body() updateUserDto: UpdateDto): Promise<UserResponseDto> {
|
||||
return this.service.update(authUser, updateUserDto);
|
||||
updateUser(@Auth() auth: AuthDto, @Body() updateUserDto: UpdateDto): Promise<UserResponseDto> {
|
||||
return this.service.update(auth, updateUserDto);
|
||||
}
|
||||
|
||||
@UseInterceptors(FileUploadInterceptor)
|
||||
@@ -85,10 +85,10 @@ export class UserController {
|
||||
@ApiBody({ description: 'A new avatar for the user', type: CreateProfileImageDto })
|
||||
@Post('profile-image')
|
||||
createProfileImage(
|
||||
@AuthUser() authUser: AuthUserDto,
|
||||
@Auth() auth: AuthDto,
|
||||
@UploadedFile() fileInfo: Express.Multer.File,
|
||||
): Promise<CreateProfileImageResponseDto> {
|
||||
return this.service.createProfileImage(authUser, fileInfo);
|
||||
return this.service.createProfileImage(auth, fileInfo);
|
||||
}
|
||||
|
||||
@Get('profile-image/:id')
|
||||
|
||||
Reference in New Issue
Block a user