Skip to content

Commit

Permalink
Login bug solved
Browse files Browse the repository at this point in the history
  • Loading branch information
Robotboyx committed Dec 12, 2019
1 parent 53471fd commit 19aba4b
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,20 @@ router.get(
var userImgUrl = result.rows[0].img_url;
req.session.passport.user.role = userRole;
req.session.passport.user.apartment = userApartment;

if (userImgUrl == null || userImgUrl != req.user.image) {
pool.query("UPDATE account SET img_url = $1 WHERE email = $2;", [req.user.image, req.user.email], function (err, result1) {
if (err) { res.send(err)}
else {
next();
}
})
} else {
next()
}

// console.log("userImgUrl",userImgUrl);
// console.log("userImgUrl",req.user)
// if (userImgUrl == null || userImgUrl != req.user.image || userImgUrl == undefined) {
// pool.query("UPDATE account SET img_url = $1 WHERE email = $2;", [req.user.image, req.user.email], function (err, result1) {
// if (err) { res.send(err)}
// else {
// next();
// }
// })
// } else {
// next()
// }
next()

} else {
res.send("Sorry " + req.user.displayName + "! We couldn't find your account in our database! Please contact our adminstrator to add you in!")
Expand Down

0 comments on commit 19aba4b

Please sign in to comment.