Google login: Log out if wrong account

This commit is contained in:
Guangcong Luo 2017-09-13 16:35:41 -04:00
parent 248f4a0887
commit b557eafefb
2 changed files with 9 additions and 5 deletions

View File

@ -948,10 +948,9 @@
'theme': 'dark',
'onsuccess': function (googleUser) {
var profile = googleUser.getBasicProfile();
var email = profile.getEmail();
var id_token = googleUser.getAuthResponse().id_token;
self.close();
app.user.passwordRename(data.username, id_token, email);
app.user.passwordRename(data.username, id_token, data.special);
},
'onfailure': function (googleUser) {
alert('sign-in failed');

View File

@ -275,13 +275,12 @@
app.send('/trn ' + name);
}
},
passwordRename: function (name, password, email) {
passwordRename: function (name, password, special) {
var self = this;
$.post(this.getActionPHP(), {
act: 'login',
name: name,
pass: password,
email: email,
challstr: this.challstr
}, Tools.safeJSON(function (data) {
if (data && data.curuser && data.curuser.loggedin) {
@ -290,9 +289,15 @@
self.finishRename(name, data.assertion);
} else {
// wrong password
if (special === '@gmail') {
try {
gapi.auth2.getAuthInstance().signOut();
} catch (e) {}
}
app.addPopup(LoginPasswordPopup, {
username: name,
error: 'Wrong password.'
error: 'Wrong password.',
special: special
});
}
}), 'text');