2026-08-29 21:06:30 +03:30
|
|
|
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
|
|
|
|
import { AuthService } from './auth.service';
|
2026-09-05 00:47:33 +03:30
|
|
|
import {
|
|
|
|
|
LoginDto,
|
|
|
|
|
LoginVerifyOtpDto,
|
|
|
|
|
RegisterOrganizationDto,
|
|
|
|
|
RegisterVerifyOtpDto,
|
|
|
|
|
} from './dto';
|
2026-08-29 21:06:30 +03:30
|
|
|
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) {
|
2026-09-05 00:47:33 +03:30
|
|
|
return this.authService.startRegister(dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('register/verify')
|
|
|
|
|
registerVerify(@Body() dto: RegisterVerifyOtpDto) {
|
|
|
|
|
return this.authService.verifyRegister(dto);
|
2026-08-29 21:06:30 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('login')
|
|
|
|
|
login(@Body() dto: LoginDto) {
|
2026-09-05 00:47:33 +03:30
|
|
|
return this.authService.loginLegacy(dto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Post('login/verify')
|
|
|
|
|
loginVerify(@Body() dto: LoginVerifyOtpDto) {
|
|
|
|
|
return this.authService.verifyLogin(dto);
|
2026-08-29 21:06:30 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
|
|
|
@Get('me')
|
|
|
|
|
me(@CurrentUser() user: { userId: string }) {
|
|
|
|
|
return this.authService.me(user.userId);
|
|
|
|
|
}
|
|
|
|
|
}
|