mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 09:07:55 +00:00
Refactor activation code handling and user space verification
This commit is contained in:
@@ -1,20 +1,11 @@
|
||||
import { ControllerRoute } from '@app/common/constants/controller-route';
|
||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Param,
|
||||
Post,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { Controller, Get, Param, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { UserSpaceService } from '../services';
|
||||
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
|
||||
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
|
||||
import { AddUserSpaceUsingCodeDto, UserParamDto } from '../dtos';
|
||||
import { UserParamDto } from '../dtos';
|
||||
|
||||
@ApiTags('User Module')
|
||||
@Controller({
|
||||
@@ -36,36 +27,4 @@ export class UserSpaceController {
|
||||
): Promise<BaseResponseDto> {
|
||||
return this.userSpaceService.getSpacesForUser(params.userUuid);
|
||||
}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/verify-code')
|
||||
@ApiOperation({
|
||||
summary:
|
||||
ControllerRoute.USER_SPACE.ACTIONS.VERIFY_CODE_AND_ADD_USER_SPACE_SUMMARY,
|
||||
description:
|
||||
ControllerRoute.USER_SPACE.ACTIONS
|
||||
.VERIFY_CODE_AND_ADD_USER_SPACE_DESCRIPTION,
|
||||
})
|
||||
async verifyCodeAndAddUserSpace(
|
||||
@Body() dto: AddUserSpaceUsingCodeDto,
|
||||
@Param() params: UserParamDto,
|
||||
) {
|
||||
try {
|
||||
await this.userSpaceService.verifyCodeAndAddUserSpace(
|
||||
dto,
|
||||
params.userUuid,
|
||||
);
|
||||
return {
|
||||
statusCode: HttpStatus.CREATED,
|
||||
success: true,
|
||||
message: 'user space added successfully',
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user