61 lines
2.4 KiB
TypeScript
61 lines
2.4 KiB
TypeScript
import { Controller, Post, Body, UseGuards } from '@nestjs/common';
|
|
import { AuthService } from '../services/auth.service';
|
|
import { DirectLoginDto } from '../dto/direct-login.dto';
|
|
import { ApiTags, ApiOperation, ApiBody } from '@nestjs/swagger';
|
|
import { SuperAdminAuthGuard } from '../guards/superAdminAuth.guard';
|
|
|
|
@ApiTags('auth')
|
|
@Controller()
|
|
export class AuthController {
|
|
constructor(private readonly authService: AuthService) { }
|
|
|
|
// @Throttle({ default: { limit: 3, ttl: 180_000 } })
|
|
// @Post('public/auth/otp/request')
|
|
// @ApiOperation({ summary: 'Request OTP for login or signup' })
|
|
// @ApiBody({ type: RequestOtpDto, description: 'Mobile number to receive OTP' })
|
|
// otpRequest(@Body() dto: RequestOtpDto) {
|
|
// return this.authService.requestOtp(dto, false);
|
|
// }
|
|
|
|
|
|
// @RefreshTokenRateLimit()
|
|
// @ApiOperation({ summary: 'refresh the user access token / refresh token' })
|
|
// @Post('public/auth/refresh')
|
|
// refreshToken(@Body() refreshTokenDto: RefreshTokenDto) {
|
|
// return this.authService.refreshToken(refreshTokenDto.refreshToken);
|
|
// }
|
|
|
|
// @Throttle({ default: { limit: 3, ttl: 180_000 } })
|
|
// @Post('admin/auth/otp/request')
|
|
// @ApiOperation({ summary: 'Request OTP for login or signup' })
|
|
// @ApiBody({ type: RequestOtpDto, description: 'Mobile number to receive OTP' })
|
|
// otpRequestAdmin(@Body() dto: RequestOtpDto) {
|
|
// return this.authService.requestOtp(dto, true);
|
|
// }
|
|
|
|
// @Post('admin/auth/otp/verify')
|
|
// @ApiOperation({ summary: 'Verify OTP code' })
|
|
// @ApiBody({ type: VerifyOtpDto, description: 'Mobile number and OTP code' })
|
|
// otpVerifyAdmin(@Body() dto: VerifyOtpDto) {
|
|
// return this.authService.verifyOtpAdmin(dto.phone, dto.slug, dto.otp);
|
|
// }
|
|
|
|
// @RefreshTokenRateLimit()
|
|
// @ApiOperation({ summary: 'refresh the admin access token / refresh token' })
|
|
// @Post('admin/auth/refresh')
|
|
// refreshTokenAdmin(@Body() refreshTokenDto: RefreshTokenDto) {
|
|
// return this.authService.refreshToken(refreshTokenDto.refreshToken);
|
|
// }
|
|
|
|
// //super admin routes
|
|
|
|
@UseGuards(SuperAdminAuthGuard)
|
|
@Post('super-admin/auth/direct-login')
|
|
@ApiOperation({ summary: 'Direct login for DSC - returns login credentials' })
|
|
@ApiBody({ type: DirectLoginDto, description: 'Danak Subscriptionid' })
|
|
directloginForDsc(@Body() dto: DirectLoginDto) {
|
|
return this.authService.directLogin(dto.subscriptionId);
|
|
}
|
|
|
|
}
|