Skip to content

Commit

Permalink
error handling on login
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsc0301 committed Sep 13, 2023
1 parent 6b3b63e commit d1867ee
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ app.get('/login', (req, res) => {
const new_player = new Player(player_email);
const new_player_room = assign_room_for(new_player);

console.log('New player: ', new_player, new_player_room);

const body = new Response(new_player_room);

res.set(get_headers(req.headers.origin));
Expand All @@ -107,6 +109,17 @@ app.get('/room', (req, res) => {
const room_id = req.query['room_id']+'';

const response = new Response();

if(!rooms[room_id]) {
console.error('Invalid room ID');

response.error = "Invalid room ID";
response.status = BAD_REQUEST;
res.set(get_headers(req.headers.origin));
res.status(BAD_REQUEST).json(response);
return;
}

const player_is_here = rooms[room_id].player_is_here(player_email);

if(player_is_here) {
Expand Down

0 comments on commit d1867ee

Please sign in to comment.