|
@@ -4,7 +4,6 @@ import {
|
|
Post,
|
|
Post,
|
|
Body,
|
|
Body,
|
|
Param,
|
|
Param,
|
|
- UseGuards,
|
|
|
|
ValidationPipe,
|
|
ValidationPipe,
|
|
Put,
|
|
Put,
|
|
Query,
|
|
Query,
|
|
@@ -14,10 +13,9 @@ import {
|
|
ParseBoolPipe,
|
|
ParseBoolPipe,
|
|
} from '@nestjs/common';
|
|
} from '@nestjs/common';
|
|
import { UserService } from './user.service';
|
|
import { UserService } from './user.service';
|
|
-import { JwtAuthGuard } from '../../modules/immich-jwt/guards/jwt-auth.guard';
|
|
|
|
|
|
+import { Authenticated } from '../../decorators/authenticated.decorator';
|
|
import { AuthUserDto, GetAuthUser } from '../../decorators/auth-user.decorator';
|
|
import { AuthUserDto, GetAuthUser } from '../../decorators/auth-user.decorator';
|
|
import { CreateUserDto } from './dto/create-user.dto';
|
|
import { CreateUserDto } from './dto/create-user.dto';
|
|
-import { AdminRolesGuard } from '../../middlewares/admin-role-guard.middleware';
|
|
|
|
import { UpdateUserDto } from './dto/update-user.dto';
|
|
import { UpdateUserDto } from './dto/update-user.dto';
|
|
import { FileInterceptor } from '@nestjs/platform-express';
|
|
import { FileInterceptor } from '@nestjs/platform-express';
|
|
import { profileImageUploadOption } from '../../config/profile-image-upload.config';
|
|
import { profileImageUploadOption } from '../../config/profile-image-upload.config';
|
|
@@ -33,7 +31,7 @@ import { CreateProfileImageResponseDto } from './response-dto/create-profile-ima
|
|
export class UserController {
|
|
export class UserController {
|
|
constructor(private readonly userService: UserService) {}
|
|
constructor(private readonly userService: UserService) {}
|
|
|
|
|
|
- @UseGuards(JwtAuthGuard)
|
|
|
|
|
|
+ @Authenticated()
|
|
@ApiBearerAuth()
|
|
@ApiBearerAuth()
|
|
@Get()
|
|
@Get()
|
|
async getAllUsers(
|
|
async getAllUsers(
|
|
@@ -48,16 +46,15 @@ export class UserController {
|
|
return await this.userService.getUserById(userId);
|
|
return await this.userService.getUserById(userId);
|
|
}
|
|
}
|
|
|
|
|
|
- @UseGuards(JwtAuthGuard)
|
|
|
|
|
|
+ @Authenticated()
|
|
@ApiBearerAuth()
|
|
@ApiBearerAuth()
|
|
@Get('me')
|
|
@Get('me')
|
|
async getMyUserInfo(@GetAuthUser() authUser: AuthUserDto): Promise<UserResponseDto> {
|
|
async getMyUserInfo(@GetAuthUser() authUser: AuthUserDto): Promise<UserResponseDto> {
|
|
return await this.userService.getUserInfo(authUser);
|
|
return await this.userService.getUserInfo(authUser);
|
|
}
|
|
}
|
|
|
|
|
|
- @UseGuards(JwtAuthGuard)
|
|
|
|
|
|
+ @Authenticated({ admin: true })
|
|
@ApiBearerAuth()
|
|
@ApiBearerAuth()
|
|
- @UseGuards(AdminRolesGuard)
|
|
|
|
@Post()
|
|
@Post()
|
|
async createUser(
|
|
async createUser(
|
|
@Body(new ValidationPipe({ transform: true })) createUserDto: CreateUserDto,
|
|
@Body(new ValidationPipe({ transform: true })) createUserDto: CreateUserDto,
|
|
@@ -70,7 +67,7 @@ export class UserController {
|
|
return await this.userService.getUserCount();
|
|
return await this.userService.getUserCount();
|
|
}
|
|
}
|
|
|
|
|
|
- @UseGuards(JwtAuthGuard)
|
|
|
|
|
|
+ @Authenticated()
|
|
@ApiBearerAuth()
|
|
@ApiBearerAuth()
|
|
@Put()
|
|
@Put()
|
|
async updateUser(
|
|
async updateUser(
|
|
@@ -81,7 +78,7 @@ export class UserController {
|
|
}
|
|
}
|
|
|
|
|
|
@UseInterceptors(FileInterceptor('file', profileImageUploadOption))
|
|
@UseInterceptors(FileInterceptor('file', profileImageUploadOption))
|
|
- @UseGuards(JwtAuthGuard)
|
|
|
|
|
|
+ @Authenticated()
|
|
@ApiBearerAuth()
|
|
@ApiBearerAuth()
|
|
@ApiConsumes('multipart/form-data')
|
|
@ApiConsumes('multipart/form-data')
|
|
@ApiBody({
|
|
@ApiBody({
|