chore: add verfication email for user profile
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Body, Controller, Get, HttpCode, HttpStatus, Patch, Post, Query } from "@nestjs/common";
|
||||
import { Body, Controller, Get, HttpCode, HttpStatus, Patch, Post, Query, Res } from "@nestjs/common";
|
||||
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
||||
import { FastifyReply } from "fastify";
|
||||
|
||||
import { CheckValidityDTO } from "./DTO/check-validity.dto";
|
||||
import { CreateAdminDto } from "./DTO/create-admin.dto";
|
||||
@@ -9,9 +10,10 @@ import { CreateRoleDto } from "./DTO/create-role.dto";
|
||||
import { SearchAdminQueryDto } from "./DTO/search-admins-query.dto";
|
||||
import { SearchCustomersDto } from "./DTO/search-customers.dto";
|
||||
import { SearchRolesQueryDto } from "./DTO/search-roles.dto";
|
||||
import { UpdateEmailDto } from "./DTO/update-email.dto";
|
||||
import { UpdateProfileDto } from "./DTO/update-profile.dto";
|
||||
import { CreateUserGroupDto } from "./DTO/user-group.dto";
|
||||
import { User } from "./entities/user.entity";
|
||||
import { EmailVerifyQueryDto } from "./DTO/verify-email-query.dto";
|
||||
import { PermissionEnum } from "./enums/permission.enum";
|
||||
import { UsersService } from "./providers/users.service";
|
||||
import { AuthGuards } from "../../common/decorators/auth-guard.decorator";
|
||||
@@ -28,8 +30,8 @@ export class UsersController {
|
||||
@AuthGuards()
|
||||
@ApiOperation({ summary: "Get user profile" })
|
||||
@Get("me")
|
||||
getMe(@UserDec() user: User) {
|
||||
return this.usersService.getMe(user.id);
|
||||
getMe(@UserDec("id") userId: string) {
|
||||
return this.usersService.getMe(userId);
|
||||
}
|
||||
|
||||
/************************************************************ */
|
||||
@@ -37,8 +39,8 @@ export class UsersController {
|
||||
@AuthGuards()
|
||||
@ApiOperation({ summary: "Get user financial info" })
|
||||
@Get("me/financial-info")
|
||||
getFinancialInfo(@UserDec() user: User) {
|
||||
return this.usersService.getMyFinancialInfo(user.id);
|
||||
getFinancialInfo(@UserDec("id") userId: string) {
|
||||
return this.usersService.getMyFinancialInfo(userId);
|
||||
}
|
||||
|
||||
/************************************************************ */
|
||||
@@ -46,8 +48,22 @@ export class UsersController {
|
||||
@AuthGuards()
|
||||
@ApiOperation({ summary: "Update user profile" })
|
||||
@Patch("update-profile")
|
||||
updateProfile(@Body() updateProfileDto: UpdateProfileDto, @UserDec() user: User) {
|
||||
return this.usersService.updateProfile(user.id, updateProfileDto);
|
||||
updateProfile(@Body() updateProfileDto: UpdateProfileDto, @UserDec("id") userId: string) {
|
||||
return this.usersService.updateProfile(userId, updateProfileDto);
|
||||
}
|
||||
|
||||
@AuthGuards()
|
||||
@ApiOperation({ summary: "Update user email" })
|
||||
@Patch("update-email")
|
||||
updateEmail(@Body() updateEmailDto: UpdateEmailDto, @UserDec("id") userId: string) {
|
||||
return this.usersService.updateEmail(userId, updateEmailDto);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "Verify email" })
|
||||
@HttpCode(HttpStatus.PERMANENT_REDIRECT)
|
||||
@Get("verify-email")
|
||||
verifyEmail(@Query() queryDto: EmailVerifyQueryDto, @Res({ passthrough: true }) rep: FastifyReply) {
|
||||
return this.usersService.verifyEmail(queryDto, rep);
|
||||
}
|
||||
|
||||
/************************************************************ */
|
||||
@@ -56,8 +72,8 @@ export class UsersController {
|
||||
@ApiOperation({ summary: "Check validity of user field" })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post("check-validity")
|
||||
checkValidity(@Body() checkValidityDto: CheckValidityDTO, @UserDec() user: User) {
|
||||
return this.usersService.checkValidity(checkValidityDto, user.id);
|
||||
checkValidity(@Body() checkValidityDto: CheckValidityDTO, @UserDec("id") userId: string) {
|
||||
return this.usersService.checkValidity(checkValidityDto, userId);
|
||||
}
|
||||
|
||||
/************************************************************ */
|
||||
|
||||
Reference in New Issue
Block a user