fix: auth robot test

This commit is contained in:
Louis Auzuret
2022-06-20 17:10:07 +02:00
committed by Bluub
parent 061e0188f0
commit cdca0d4942
7 changed files with 115 additions and 4 deletions
+11 -1
View File
@@ -1,4 +1,4 @@
import { Controller, Request, Post, Get, UseGuards, Res, Body } from '@nestjs/common';
import { Controller, Request, Post, Get, UseGuards, Res, Body, Delete } from '@nestjs/common';
import { AuthService } from './auth.service';
import { JwtAuthGuard } from './jwt-auth.guard';
import { LocalAuthGuard } from './local-auth.guard';
@@ -40,4 +40,14 @@ export class AuthController {
getProfile(@Request() req) {
return req.user;
}
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@ApiOkResponse({ description: 'Successfully deleted' })
@ApiUnauthorizedResponse({ description: 'Invalid token' })
@Delete('me')
deleteSelf(@Request() req) {
return this.usersService.deleteUser({"id": req.user.id})
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ export class AuthService {
) {}
async validateUser(username: string, password: string): Promise<PayloadInterface> {
const user = await this.userService.user({username});
const user = await this.userService.user({username});
if (user && bcrypt.compareSync(password, user.password)) {
return {
username: user.username,