Fix ChangeManagerStatus
This commit is contained in:
parent
cec7fafa62
commit
db13a49ba9
|
@ -109,13 +109,12 @@ app.get('/auth/google/callback',
|
||||||
} else {
|
} else {
|
||||||
// User is "preregistered" with email only, so complete the registration
|
// User is "preregistered" with email only, so complete the registration
|
||||||
// This step will register the name, img and googleId
|
// This step will register the name, img and googleId
|
||||||
user.isManager = false;
|
|
||||||
tmdb.editUser(user.email, user).catch(err => console.log(err));
|
tmdb.editUser(user.email, user).catch(err => console.log(err));
|
||||||
|
|
||||||
req.session.user = user;
|
req.session.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.redirect('/');
|
res.redirect(process.env.AUTH_SUCCESS_REDIRECT);
|
||||||
return;
|
return;
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
|
@ -541,6 +541,9 @@ function createUserBlank(email) {
|
||||||
|
|
||||||
function editUser(email, user) {
|
function editUser(email, user) {
|
||||||
return new Promise(function(resolve, reject) {
|
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) => {
|
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) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
Loading…
Reference in New Issue