getting fix for deleting a user

This commit is contained in:
Me
2023-01-17 16:00:35 +01:00
4 changed files with 11 additions and 11 deletions

View File

@@ -146,6 +146,7 @@ export class ChatService {
const user_db = await this.getUserByName(username); const user_db = await this.getUserByName(username);
printCaller("-- out "); printCaller("-- out ");
if (user_db)
return user_db.currentRoom; return user_db.currentRoom;
} }

View File

@@ -1,5 +1,5 @@
import { import {
Body, Controller, Delete, Get, NotFoundException,HttpStatus, Param, Patch, Post, Query, Redirect, Req, Res, UploadedFile, UseGuards, UseInterceptors, Next, Body, Controller, Delete, Get, NotFoundException,HttpStatus, Next, Patch, Post, Query, Redirect, Req, Res, UploadedFile, UseGuards, UseInterceptors
} from '@nestjs/common'; } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express'; import { FileInterceptor } from '@nestjs/platform-express';
import { Response } from 'express'; import { Response } from 'express';
@@ -73,14 +73,14 @@ export class UsersController {
@UseGuards(AuthenticateGuard) @UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard) @UseGuards(TwoFactorGuard)
@Delete() @Delete()
remove(@Req() request, @Res() response, @Next() next) { remove(@Req() req, @Res() response, @Next() next) {
this.usersService.remove(request.user.id); this.usersService.remove(req.user.id);
request.logout(function(err) { req.logout(function(err) {
if (err) { return next(err); } if (err) { return next(err); }
response.redirect('/'); response.redirect('/');
}); });
request.session.cookie.maxAge = 0; req.session.cookie.maxAge = 0;
return {msg : 'You have deleted your account'}; return {msg : 'Your account has been deleted'};
} }

View File

@@ -125,7 +125,6 @@
}); });
} }
</script> </script>