added severall protections
This commit is contained in:
@@ -231,6 +231,13 @@ export class ChatController {
|
|||||||
console.log("throw error: error: true, code: 'BLOCKED_USER', message: 'you cannot enter this room, you blocked this user'");
|
console.log("throw error: error: true, code: 'BLOCKED_USER', message: 'you cannot enter this room, you blocked this user'");
|
||||||
throw new HttpException({ error: true, code: 'BLOCKED_USER', message: `you cannot enter this room, you blocked this user` }, HttpStatus.UNAUTHORIZED);
|
throw new HttpException({ error: true, code: 'BLOCKED_USER', message: `you cannot enter this room, you blocked this user` }, HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const find_room = await this.chatService.getRoomByName(`${req.user.username} + ${room.name}`);
|
||||||
|
if (find_room)
|
||||||
|
{
|
||||||
|
console.log("throw error: error: true, code: 'ROOM_CONFLICT', message: 'This room name already exist'");
|
||||||
|
throw new HttpException({ error: true, code: 'ROOM_CONFLICT', message: `This room name already exist` }, HttpStatus.CONFLICT);
|
||||||
|
}
|
||||||
room.type = 'direct';
|
room.type = 'direct';
|
||||||
room.users = [room.name, req.user.username];
|
room.users = [room.name, req.user.username];
|
||||||
room.name += ` + ${req.user.username}`;
|
room.name += ` + ${req.user.username}`;
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
let users: User[] = list_block_user();
|
let users: User[] = list_block_user();
|
||||||
|
|
||||||
function user_profile(room_user: string)
|
async function user_profile(room_user: string)
|
||||||
{
|
{
|
||||||
to_print("in user_profile");
|
to_print("in user_profile");
|
||||||
settings_user.set(room_user);
|
await settings_user.set(room_user);
|
||||||
layout.set("user");
|
layout.set("user");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user