mirror of
https://github.com/jakobkordez/ham-reserve.git
synced 2025-08-04 04:07:40 +00:00
Initial commit
This commit is contained in:
31
nest-api/src/auth/auth.controller.ts
Normal file
31
nest-api/src/auth/auth.controller.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { Controller, Get, Post, UseGuards } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { Public } from 'src/decorators/public.decorator';
|
||||
import { RequestUser } from 'src/decorators/request-user.decorator';
|
||||
import { LocalAuthGuard } from './guards/local-auth.guard';
|
||||
import { RefreshAuthGuard } from './guards/refresh-auth.guard';
|
||||
import { UserTokenData } from './interfaces/user-token-data.interface';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
constructor(private authService: AuthService) {}
|
||||
|
||||
@Public()
|
||||
@UseGuards(LocalAuthGuard)
|
||||
@Post('login')
|
||||
login(@RequestUser() user: UserTokenData) {
|
||||
return this.authService.login(user);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@UseGuards(RefreshAuthGuard)
|
||||
@Get('refresh')
|
||||
refresh(@RequestUser() user: UserTokenData) {
|
||||
return this.authService.login(user);
|
||||
}
|
||||
|
||||
@Get('logout')
|
||||
logout(@RequestUser() user: UserTokenData): Promise<void> {
|
||||
return this.authService.logout(user.id);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user