From 814ddbf2cae522c96d6093d045cd5f9f9c26f710 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Mon, 25 Apr 2022 14:01:23 +0200 Subject: [PATCH] bugfix: delete logged in user --- src/server/tmdb.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/server/tmdb.js b/src/server/tmdb.js index c44fd1f..982e878 100644 --- a/src/server/tmdb.js +++ b/src/server/tmdb.js @@ -485,13 +485,17 @@ function getUserByGoogleId(googleId) { console.log(err); reject(err); } else { - if (users.length == 0) { + if (!users || users.length == 0) { + reject("No such user exists"); + } + try { + users[0].isManager = users[0].isManager == 1; + users[0].asuraId = users[0].id; + users[0].id = undefined; + resolve(users[0]); + } catch (e) { reject("No such user exists"); } - users[0].isManager = users[0].isManager == 1; - users[0].asuraId = users[0].id; - users[0].id = undefined; - resolve(users[0]); } }); });