sign in to existing email account with new google sign-in
This commit is contained in:
parent
271df7f2fd
commit
f9b239657c
|
@ -62,6 +62,13 @@ function setupPassport(passport: PassportStatic) {
|
||||||
if (otherAccountWSameGoogle) {
|
if (otherAccountWSameGoogle) {
|
||||||
return done(null, otherAccountWSameGoogle);
|
return done(null, otherAccountWSameGoogle);
|
||||||
}
|
}
|
||||||
|
// if the person used their google email for a plain signup, add the google provider to it and sign in
|
||||||
|
const googleMail = profile.emails && profile.emails[0].value;
|
||||||
|
if (googleMail) {
|
||||||
|
const otherAccountWSameEmail = await getLingdocsUser("email", googleMail);
|
||||||
|
otherAccountWSameEmail && await updateLingdocsUser(otherAccountWSameEmail?.userId, { google: gProfile });
|
||||||
|
return done(null, otherAccountWSameEmail);
|
||||||
|
}
|
||||||
const u = await updateLingdocsUser(req.user.userId, { google: gProfile });
|
const u = await updateLingdocsUser(req.user.userId, { google: gProfile });
|
||||||
if (!u.email) {
|
if (!u.email) {
|
||||||
// if the user is adding a google account and doesn't have a previous email, add the google email
|
// if the user is adding a google account and doesn't have a previous email, add the google email
|
||||||
|
|
Loading…
Reference in New Issue