Files
CRM_Montzar/apps/api/src/auth/auth.controller.ts
T

42 lines
1.0 KiB
TypeScript
Raw Normal View History

import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
import { AuthService } from './auth.service';
import {
LoginDto,
LoginVerifyOtpDto,
RegisterOrganizationDto,
RegisterVerifyOtpDto,
} from './dto';
import { JwtAuthGuard } from './jwt-auth.guard';
import { CurrentUser } from './current-user.decorator';
@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}
@Post('register')
register(@Body() dto: RegisterOrganizationDto) {
return this.authService.startRegister(dto);
}
@Post('register/verify')
registerVerify(@Body() dto: RegisterVerifyOtpDto) {
return this.authService.verifyRegister(dto);
}
@Post('login')
login(@Body() dto: LoginDto) {
return this.authService.loginLegacy(dto);
}
@Post('login/verify')
loginVerify(@Body() dto: LoginVerifyOtpDto) {
return this.authService.verifyLogin(dto);
}
@UseGuards(JwtAuthGuard)
@Get('me')
me(@CurrentUser() user: { userId: string }) {
return this.authService.me(user.userId);
}
}