diff --git a/srcs/requirements/nestjs/api_back/src/chat/chat.controller.ts b/srcs/requirements/nestjs/api_back/src/chat/chat.controller.ts index b87d18c5..4f789b25 100644 --- a/srcs/requirements/nestjs/api_back/src/chat/chat.controller.ts +++ b/srcs/requirements/nestjs/api_back/src/chat/chat.controller.ts @@ -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 + @Post('passwordauth') + async passwordAuthentication(@Body() room: roomDto, @Req() req, @Res() res): Promise { 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 + { + 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') diff --git a/srcs/requirements/svelte/api_front/src/pieces/chat/Chat.svelte b/srcs/requirements/svelte/api_front/src/pieces/chat/Chat.svelte index 06b2ef15..ad691fc8 100644 --- a/srcs/requirements/svelte/api_front/src/pieces/chat/Chat.svelte +++ b/srcs/requirements/svelte/api_front/src/pieces/chat/Chat.svelte @@ -1,7 +1,7 @@ - -
-

temp, for testing :

- - - - - - - - - - - -