2
0
Fork 0

MOBILE-2853 login: Open browser to reconnect if oauth is still valid

main
Dani Palou 2020-01-20 12:03:23 +01:00
parent f5a28ad584
commit 59620ff33f
2 changed files with 37 additions and 0 deletions

View File

@ -88,6 +88,8 @@ export class CoreLoginReconnectPage {
this.username = site.infos.username;
this.siteUrl = site.infos.siteurl;
this.siteName = site.getSiteName();
// If login was OAuth we should only reach this page if the OAuth method ID has changed.
this.isOAuth = site.isOAuth();
// Show logo instead of avatar if it's a fixed site.

View File

@ -1086,6 +1086,41 @@ export class CoreLoginHelperProvider {
});
}
} else {
if (currentSite.isOAuth()) {
// User authenticated using an OAuth method. Check if it's still valid.
const identityProviders = this.getValidIdentityProviders(result.config);
const providerToUse = identityProviders.find((provider) => {
const params = this.urlUtils.extractUrlParams(provider.url);
return params.id == currentSite.getOAuthId();
});
if (providerToUse) {
if (!this.appProvider.isSSOAuthenticationOngoing() && !this.isSSOConfirmShown && !this.waitingForBrowser) {
// Open browser to perform the OAuth.
this.isSSOConfirmShown = true;
const confirmMessage = this.translate.instant('core.login.' +
(currentSite.isLoggedOut() ? 'loggedoutssodescription' : 'reconnectssodescription'));
this.domUtils.showConfirm(confirmMessage).then(() => {
this.waitingForBrowser = true;
this.sitesProvider.unsetCurrentSite(); // Unset current site to make authentication work fine.
this.openBrowserForOAuthLogin(siteUrl, providerToUse, result.config.launchurl, data.pageName,
data.params);
}).catch(() => {
// User cancelled, logout him.
this.sitesProvider.logout();
}).finally(() => {
this.isSSOConfirmShown = false;
});
}
return;
}
}
const info = currentSite.getInfo();
if (typeof info != 'undefined' && typeof info.username != 'undefined') {
const rootNavCtrl = this.appProvider.getRootNavController(),