Merge pull request #1872 from dpalou/MOBILE-2996

MOBILE-2996 login: Prevent overriding user if sso+logout
main
Juan Leyva 2019-05-01 19:15:17 +02:00 committed by GitHub
commit 508c9301f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 16 deletions

View File

@ -439,22 +439,8 @@ export class CoreLoginHelperProvider {
* @return {Promise<any>} Promise resolved when the user is authenticated with the token. * @return {Promise<any>} Promise resolved when the user is authenticated with the token.
*/ */
handleSSOLoginAuthentication(siteUrl: string, token: string, privateToken?: string): Promise<any> { handleSSOLoginAuthentication(siteUrl: string, token: string, privateToken?: string): Promise<any> {
if (this.sitesProvider.isLoggedIn()) { // Always create a new site to prevent overriding data if another user credentials were introduced.
// User logged in, he is reconnecting. Retrieve username. return this.sitesProvider.newSite(siteUrl, token, privateToken);
const info = this.sitesProvider.getCurrentSite().getInfo();
if (typeof info != 'undefined' && typeof info.username != 'undefined') {
return this.sitesProvider.updateSiteToken(info.siteurl, info.username, token, privateToken).then(() => {
return this.sitesProvider.updateSiteInfoByUrl(info.siteurl, info.username);
}, () => {
// Error updating token, return proper error message.
return Promise.reject(this.translate.instant('core.login.errorupdatesite'));
});
}
return Promise.reject(this.translate.instant('core.login.errorupdatesite'));
} else {
return this.sitesProvider.newSite(siteUrl, token, privateToken);
}
} }
/** /**