wip change password

+ little clean in files, delete some
This commit is contained in:
simplonco
2023-01-15 01:05:57 +01:00
parent f3d0af4738
commit 1a7091679b
11 changed files with 74 additions and 93 deletions

View File

@@ -203,13 +203,7 @@ export class ChatController {
printCaller("- in ");
let fields = ["protection", "allowed_users"];
//const room_db = await this.chatService.getRoomByName(room.name, fields);
const room_db = await this.chatService.getRoomByName(room.name);
console.log("room.name:", room.name);
console.log("room_db:", room_db);
const all_rooms = await this.chatService.getAllRooms();
console.log("all_rooms:", all_rooms);
const room_db = await this.chatService.getRoomByName(room.name, fields);
if (room_db.protection === true)
{
@@ -231,8 +225,8 @@ export class ChatController {
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
@Post('password')
async setPassword(@Body() room: roomDto, @Req() req, @Res() res): Promise<void>
@Post('passwordauth')
async passwordAuthentication(@Body() room: roomDto, @Req() req, @Res() res): Promise<void>
{
printCaller("- in ");
@@ -254,6 +248,21 @@ export class ChatController {
printCaller("- out ");
}
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
@Post('changepassword')
async changePassword(@Body('room') room: roomDto, @Body('old_password') old_password: string, @Req() req, @Res() res): Promise<void>
{
printCaller("- in ");
let socket: socketDto = this.chatGateway.sockets.get(req.user.username);
await this.chatService.addPassword(req.user.username, room, socket, old_password);
const ret_room = this.format_room(room);
res.status(HttpStatus.OK).json({ room: ret_room });
printCaller("- out ");
}
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
@Post('invite')