Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1x 1x 1x 4x 1x 1x 1x 2x 2x 1x | import { Controller, Post, Req, UseGuards, Headers } from '@nestjs/common';
import { AuthService } from './auth.service';
@Controller('auth')
export class AuthController {
constructor(private authService: AuthService) {}
@Post('login')
async login(@Req() req) {
return this.authService.login(req.body.username, req.body.password);
}
@Post('logout')
async logout(@Headers('authorization') authHeader: string) {
const token = authHeader?.replace('Bearer ', '');
if (!token) return { message: 'No token provided' };
return this.authService.logout(token);
}
}
|