MOBILE-2996 login: Prevent overriding user if sso+logout

main
Dani Palou 2019-04-26 09:31:12 +02:00
parent b73b3d2727
commit 1b8b142646
1 changed files with 2 additions and 16 deletions

View File

@ -442,23 +442,9 @@ 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.
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); return this.sitesProvider.newSite(siteUrl, token, privateToken);
} }
}
/** /**
* Check if the app is configured to use several fixed URLs. * Check if the app is configured to use several fixed URLs.