From db13a49ba9c6e82136bf1ffc1bbbfe233618eb2f Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sun, 24 Apr 2022 13:23:41 +0200 Subject: [PATCH] Fix ChangeManagerStatus --- src/server/index.js | 3 +-- src/server/tmdb.js | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/index.js b/src/server/index.js index 3ec56f0..b36df84 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -109,13 +109,12 @@ app.get('/auth/google/callback', } else { // User is "preregistered" with email only, so complete the registration // This step will register the name, img and googleId - user.isManager = false; tmdb.editUser(user.email, user).catch(err => console.log(err)); req.session.user = user; } - res.redirect('/'); + res.redirect(process.env.AUTH_SUCCESS_REDIRECT); return; }) .catch(err => { diff --git a/src/server/tmdb.js b/src/server/tmdb.js index 55e6087..c825d1c 100644 --- a/src/server/tmdb.js +++ b/src/server/tmdb.js @@ -541,6 +541,9 @@ function createUserBlank(email) { function editUser(email, user) { return new Promise(function(resolve, reject) { + if (!user.isManager) { // If isManager is not defined (or false) + user.isManager = false; + } connection.query("UPDATE users SET googleId = ?, name = ?, isManager = ? WHERE email = ?", [escapeString(user.googleId), escapeString(user.name), escapeString(user.isManager), escapeString(email)], (err, sets) => { if (err) { console.log(err);