diff --git a/src/core/features/login/pages/reconnect/reconnect.html b/src/core/features/login/pages/reconnect/reconnect.html index a059b4816..f844c6178 100644 --- a/src/core/features/login/pages/reconnect/reconnect.html +++ b/src/core/features/login/pages/reconnect/reconnect.html @@ -10,94 +10,103 @@ -
-
- - {{ 'core.pictureof' | translate:{$a: userFullName} }} + +
+
+ + {{ 'core.pictureof' | translate:{$a: userFullName} }} - - -

- -

-

{{siteUrl}}

- -
- - - -

{{username}}

-
-
- - {{ 'core.login.password' | translate }} - - - - - -
- - {{ 'core.login.cancel' | translate }} - - + {{ 'core.login.password' | translate }} + + + + + +
+ + {{ 'core.login.cancel' | translate }} + + +
+ + -
- - - - + - - - - - - - - - - - - - {{ 'core.login.cancel' | translate }} - - -
+ + + + {{ 'core.login.cancel' | translate }} + + +
+ diff --git a/src/core/features/login/pages/reconnect/reconnect.ts b/src/core/features/login/pages/reconnect/reconnect.ts index 0c5ca4c23..f4656d9d9 100644 --- a/src/core/features/login/pages/reconnect/reconnect.ts +++ b/src/core/features/login/pages/reconnect/reconnect.ts @@ -49,10 +49,12 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { identityProviders?: CoreSiteIdentityProvider[]; showForgottenPassword = true; showSiteAvatar = false; + isBrowserSSO = false; isOAuth = false; isLoggedOut: boolean; siteId!: string; showScanQR = false; + showLoading = true; protected siteConfig?: CoreSitePublicConfigResponse; protected viewLeft = false; @@ -107,6 +109,8 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { this.showSiteAvatar = !!this.userAvatar && !CoreLoginHelper.getFixedSites(); this.checkSiteConfig(site); + + this.showLoading = false; } catch (error) { CoreDomUtils.showErrorModal(error); @@ -151,6 +155,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { CoreEvents.trigger(CoreEvents.LOGIN_SITE_CHECKED, { config: this.siteConfig }); } + this.isBrowserSSO = !this.isOAuth && CoreLoginHelper.isSSOLoginNeeded(this.siteConfig.typeoflogin); this.showScanQR = CoreLoginHelper.displayQRInSiteScreen() || CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); @@ -251,6 +256,23 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { CoreLoginHelper.forgottenPasswordClicked(this.siteUrl, this.username, this.siteConfig); } + /** + * Open browser for SSO login. + */ + openBrowserSSO(): void { + if (!this.siteConfig) { + return; + } + + CoreLoginHelper.confirmAndOpenBrowserForSSOLogin( + this.siteUrl, + this.siteConfig.typeoflogin, + undefined, + this.siteConfig.launchurl, + this.redirectData, + ); + } + /** * An OAuth button was clicked. * diff --git a/src/core/features/mainmenu/guards/auth.ts b/src/core/features/mainmenu/guards/auth.ts index 9ccedd13a..1497a2a8b 100644 --- a/src/core/features/mainmenu/guards/auth.ts +++ b/src/core/features/mainmenu/guards/auth.ts @@ -15,6 +15,7 @@ import { Injectable } from '@angular/core'; import { CanLoad, CanActivate, UrlTree } from '@angular/router'; import { CoreLoginHelper } from '@features/login/services/login-helper'; +import { CoreApp } from '@services/app'; import { CoreSites } from '@services/sites'; import { Router } from '@singletons'; @@ -45,9 +46,22 @@ export class CoreMainMenuAuthGuard implements CanLoad, CanActivate { } if (CoreLoginHelper.isSiteLoggedOut()) { - await CoreSites.logout(); + // Send the user to reconnect page. + const newRoute = Router.parseUrl('/login/reconnect'); + const siteId = CoreSites.getCurrentSiteId(); - return Router.parseUrl('/login'); + // Pass redirect data (if any and belongs to same site). + let redirect = CoreApp.consumeMemoryRedirect(); + if (!redirect?.timemodified || Date.now() - redirect.timemodified > 20000 || redirect.siteId !== siteId) { + redirect = null; + } + + newRoute.queryParams = { + siteId, + ...redirect, + }; + + return newRoute; } return true;