forked from EVOgeek/Vmeda.Online
MOBILE-2853 login: Open browser to reconnect if oauth is still valid
parent
f5a28ad584
commit
59620ff33f
|
@ -88,6 +88,8 @@ export class CoreLoginReconnectPage {
|
||||||
this.username = site.infos.username;
|
this.username = site.infos.username;
|
||||||
this.siteUrl = site.infos.siteurl;
|
this.siteUrl = site.infos.siteurl;
|
||||||
this.siteName = site.getSiteName();
|
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();
|
this.isOAuth = site.isOAuth();
|
||||||
|
|
||||||
// Show logo instead of avatar if it's a fixed site.
|
// Show logo instead of avatar if it's a fixed site.
|
||||||
|
|
|
@ -1086,6 +1086,41 @@ export class CoreLoginHelperProvider {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} 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();
|
const info = currentSite.getInfo();
|
||||||
if (typeof info != 'undefined' && typeof info.username != 'undefined') {
|
if (typeof info != 'undefined' && typeof info.username != 'undefined') {
|
||||||
const rootNavCtrl = this.appProvider.getRootNavController(),
|
const rootNavCtrl = this.appProvider.getRootNavController(),
|
||||||
|
|
Loading…
Reference in New Issue