81 lines
2.0 KiB
TypeScript
81 lines
2.0 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Put,
|
|
Delete,
|
|
Param,
|
|
Body,
|
|
HttpCode,
|
|
UseGuards,
|
|
Req,
|
|
} from '@nestjs/common';
|
|
import { AuthService } from './auth.service';
|
|
import { userLoginValidator } from './login/dtoValidator';
|
|
import { userSelectValidator } from './select/dtoValidator';
|
|
import { userLogoutValidator } from './logout/dtoValidator';
|
|
import { AuthControlGuard } from '../middleware/access-control.guard';
|
|
import { userCreatePasswordValidator } from './password/create/dtoValidator';
|
|
import { userChangePasswordValidator } from './password/change/dtoValidator';
|
|
|
|
@Controller('auth')
|
|
export class AuthController {
|
|
constructor(private readonly authService: AuthService) {}
|
|
|
|
@Post('login')
|
|
@HttpCode(200)
|
|
async login(@Body() query: userLoginValidator) {
|
|
return await this.authService.login(query);
|
|
}
|
|
|
|
@Post('select')
|
|
@HttpCode(200)
|
|
@UseGuards(AuthControlGuard)
|
|
async select(@Body() query: userSelectValidator, @Req() req: Request) {
|
|
return await this.authService.select(query, req);
|
|
}
|
|
|
|
@Post('/password/create')
|
|
@HttpCode(200)
|
|
async createPassword(@Body() query: userCreatePasswordValidator) {
|
|
return await this.authService.createPassword(query);
|
|
}
|
|
|
|
@Post('/password/change')
|
|
@HttpCode(200)
|
|
@UseGuards(AuthControlGuard)
|
|
async changePassword(
|
|
@Body() query: userChangePasswordValidator,
|
|
@Req() req: Request,
|
|
) {
|
|
return await this.authService.changePassword(query, req);
|
|
}
|
|
|
|
@Post('/password/reset')
|
|
@HttpCode(200)
|
|
async resetPassword() {
|
|
return { message: 'Password reset successfully' };
|
|
}
|
|
|
|
@Post('/password/verify-otp')
|
|
@HttpCode(200)
|
|
@UseGuards(AuthControlGuard)
|
|
async verifyOtp() {
|
|
return { message: 'Password verified successfully' };
|
|
}
|
|
|
|
@Post('logout')
|
|
@HttpCode(200)
|
|
@UseGuards(AuthControlGuard)
|
|
async logout(@Body() query: userLogoutValidator) {
|
|
return { message: 'Logout successful' };
|
|
}
|
|
|
|
@Post('disconnect')
|
|
@HttpCode(200)
|
|
@UseGuards(AuthControlGuard)
|
|
async disconnect() {
|
|
return { message: 'Disconnect successful' };
|
|
}
|
|
}
|