MOBILE-2915 core: Fix redirect to logged out sites

main
Dani Palou 2019-03-29 11:07:36 +01:00
parent 879792ac11
commit b16eb29ac0
3 changed files with 13 additions and 10 deletions

View File

@ -55,7 +55,8 @@ export class CoreLoginInitPage {
.then((loggedIn) => { .then((loggedIn) => {
if (loggedIn) { if (loggedIn) {
return this.navCtrl.setRoot(redirectData.page, redirectData.params, { animate: false }); return this.loginHelper.goToSiteInitialPage(this.navCtrl, redirectData.page, redirectData.params,
{ animate: false });
} }
}).catch(() => { }).catch(() => {
// Site doesn't exist. // Site doesn't exist.

View File

@ -146,12 +146,8 @@ export class CoreLoginReconnectPage {
// Reset fields so the data is not in the view anymore. // Reset fields so the data is not in the view anymore.
this.credForm.controls['password'].reset(); this.credForm.controls['password'].reset();
if (this.pageName) { // Go to the site initial page.
// Page defined, go to that page instead of site initial page. return this.loginHelper.goToSiteInitialPage(this.navCtrl, this.pageName, this.pageParams);
return this.navCtrl.setRoot(this.pageName, this.pageParams);
} else {
return this.loginHelper.goToSiteInitialPage();
}
}).catch((error) => { }).catch((error) => {
// Error, go back to login page. // Error, go back to login page.
this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true); this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true);

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { Platform, AlertController } from 'ionic-angular'; import { Platform, AlertController, NavController, NavOptions } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { CoreAppProvider } from '@providers/app'; import { CoreAppProvider } from '@providers/app';
import { CoreConfigProvider } from '@providers/config'; import { CoreConfigProvider } from '@providers/config';
@ -416,14 +416,20 @@ export class CoreLoginHelperProvider {
/** /**
* Go to the initial page of a site depending on 'userhomepage' setting. * Go to the initial page of a site depending on 'userhomepage' setting.
* *
* @param {NavController} [navCtrl] NavController to use. Defaults to app root NavController.
* @param {string} [page] Name of the page to load after loading the main page.
* @param {any} [params] Params to pass to the page.
* @param {NavOptions} [options] Navigation options.
* @return {Promise<any>} Promise resolved when done. * @return {Promise<any>} Promise resolved when done.
*/ */
goToSiteInitialPage(): Promise<any> { goToSiteInitialPage(navCtrl?: NavController, page?: string, params?: any, options?: NavOptions): Promise<any> {
navCtrl = navCtrl || this.appProvider.getRootNavController();
// Due to DeepLinker, we need to remove the path from the URL before going to main menu. // Due to DeepLinker, we need to remove the path from the URL before going to main menu.
// IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL. // IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL.
this.location.replaceState(''); this.location.replaceState('');
return this.appProvider.getRootNavController().setRoot('CoreMainMenuPage'); return navCtrl.setRoot('CoreMainMenuPage', { redirectPage: page, redirectParams: params }, options);
} }
/** /**