forked from Yara724/api
Initial commit after migration to gitea
This commit is contained in:
45
src/auth/auth-controllers/user/user.auth.controller.ts
Normal file
45
src/auth/auth-controllers/user/user.auth.controller.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Post,
|
||||
Req,
|
||||
UseGuards,
|
||||
} from "@nestjs/common";
|
||||
import { ApiAcceptedResponse, ApiBody, ApiTags } from "@nestjs/swagger";
|
||||
import { UserAuthService } from "src/auth/auth-services/user.auth.service";
|
||||
import { UserLoginDto } from "src/auth/dto/user/login.dto";
|
||||
import { UserVerifyOtp } from "src/auth/dto/user/verify.dto";
|
||||
import { LocalUserAuthGuard } from "src/auth/guards/user-local.guard";
|
||||
import { CurrentUser } from "src/decorators/user.decorator";
|
||||
|
||||
@Controller("user")
|
||||
@ApiTags("user")
|
||||
export class UserAuthController {
|
||||
constructor(private readonly userAuthService: UserAuthService) {}
|
||||
|
||||
@Post("/send-otp")
|
||||
@ApiBody({
|
||||
type: UserLoginDto,
|
||||
description: "user login api -- call this api and send otp",
|
||||
})
|
||||
@ApiAcceptedResponse()
|
||||
async sendOtpRq(@Body() body: UserLoginDto) {
|
||||
const res = await this.userAuthService.sendOtpRequest(body.mobile);
|
||||
if (res) {
|
||||
throw new HttpException(res, HttpStatus.ACCEPTED);
|
||||
}
|
||||
}
|
||||
|
||||
@Post("/login")
|
||||
@UseGuards(LocalUserAuthGuard)
|
||||
@ApiBody({
|
||||
type: UserVerifyOtp,
|
||||
description: "user verify otp -- call this api and get a tokens",
|
||||
})
|
||||
@ApiAcceptedResponse()
|
||||
async login(@Body() body, @Req() req, @CurrentUser() user) {
|
||||
return await this.userAuthService.login(req.user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user