-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from pre-onboarding-backend-G/feature/user#36
사용자 가입승인(API) 이메일 서비스 구현 #36
- Loading branch information
Showing
4 changed files
with
69 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ import { JwtAuthGuard } from './guards/jwt-auth.guard'; | |
import { Response } from 'express'; | ||
import { GetUser } from './decorators/user.decorator'; | ||
import { User } from 'src/user/schema/user.schema'; | ||
import { RegisterUserDto } from 'src/user/dto/registerUserDto'; | ||
import { RegisterUserDto } from 'src/user/dto/register-user.dto'; | ||
|
||
@ApiTags('auth') | ||
@Controller('auth') | ||
|
@@ -109,20 +109,21 @@ export class AuthController { | |
@Post('register') | ||
async Register( | ||
@Body(ValidationPipe) registerUserDto: RegisterUserDto, | ||
@Res() res: Response, | ||
) { | ||
try { | ||
const createdUser = await this.authService.register(registerUserDto); | ||
const token = await this.authService.login(createdUser); | ||
res.status(HttpStatus.CREATED).json({ token }); | ||
} catch (error) { | ||
if (error.status === HttpStatus.CONFLICT) { | ||
res.status(HttpStatus.CONFLICT).json({ message: error.message }); | ||
} else { | ||
res | ||
.status(HttpStatus.INTERNAL_SERVER_ERROR) | ||
.json({ message: '서버 오류' }); | ||
} | ||
} | ||
): Promise<void> { | ||
await this.authService.register(registerUserDto); | ||
} | ||
|
||
@Post('verify') | ||
@ApiBody({ | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
email: { type: 'string', example: '[email protected]' }, | ||
code: { type: 'string', example: '123456' }, | ||
}, | ||
}, | ||
}) | ||
async verify(@Body() body: { email: string; code: string }): Promise<void> { | ||
return this.authService.verify(body.email, body.code); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface VerificationData { | ||
email: string; | ||
password: string; | ||
connectedServices: any[]; // 실제 타입에 맞게 변경해주세요. | ||
code: string; | ||
expires: number; | ||
} |
File renamed without changes.