Fix ChangeManagerStatus

This commit is contained in:
Felix Albrigtsen 2022-04-24 13:23:41 +02:00
parent cec7fafa62
commit db13a49ba9
2 changed files with 4 additions and 2 deletions

View File

@ -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 => {

View File

@ -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);