Skip to content

Commit b16eb29

Browse files
committed
MOBILE-2915 core: Fix redirect to logged out sites
1 parent 879792a commit b16eb29

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/core/login/pages/init/init.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export class CoreLoginInitPage {
5555
.then((loggedIn) => {
5656

5757
if (loggedIn) {
58-
return this.navCtrl.setRoot(redirectData.page, redirectData.params, { animate: false });
58+
return this.loginHelper.goToSiteInitialPage(this.navCtrl, redirectData.page, redirectData.params,
59+
{ animate: false });
5960
}
6061
}).catch(() => {
6162
// Site doesn't exist.

src/core/login/pages/reconnect/reconnect.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,8 @@ export class CoreLoginReconnectPage {
146146
// Reset fields so the data is not in the view anymore.
147147
this.credForm.controls['password'].reset();
148148

149-
if (this.pageName) {
150-
// Page defined, go to that page instead of site initial page.
151-
return this.navCtrl.setRoot(this.pageName, this.pageParams);
152-
} else {
153-
return this.loginHelper.goToSiteInitialPage();
154-
}
149+
// Go to the site initial page.
150+
return this.loginHelper.goToSiteInitialPage(this.navCtrl, this.pageName, this.pageParams);
155151
}).catch((error) => {
156152
// Error, go back to login page.
157153
this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true);

src/core/login/providers/helper.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import { Injectable } from '@angular/core';
1616
import { Location } from '@angular/common';
17-
import { Platform, AlertController } from 'ionic-angular';
17+
import { Platform, AlertController, NavController, NavOptions } from 'ionic-angular';
1818
import { TranslateService } from '@ngx-translate/core';
1919
import { CoreAppProvider } from '@providers/app';
2020
import { CoreConfigProvider } from '@providers/config';
@@ -416,14 +416,20 @@ export class CoreLoginHelperProvider {
416416
/**
417417
* Go to the initial page of a site depending on 'userhomepage' setting.
418418
*
419+
* @param {NavController} [navCtrl] NavController to use. Defaults to app root NavController.
420+
* @param {string} [page] Name of the page to load after loading the main page.
421+
* @param {any} [params] Params to pass to the page.
422+
* @param {NavOptions} [options] Navigation options.
419423
* @return {Promise<any>} Promise resolved when done.
420424
*/
421-
goToSiteInitialPage(): Promise<any> {
425+
goToSiteInitialPage(navCtrl?: NavController, page?: string, params?: any, options?: NavOptions): Promise<any> {
426+
navCtrl = navCtrl || this.appProvider.getRootNavController();
427+
422428
// Due to DeepLinker, we need to remove the path from the URL before going to main menu.
423429
// IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL.
424430
this.location.replaceState('');
425431

426-
return this.appProvider.getRootNavController().setRoot('CoreMainMenuPage');
432+
return navCtrl.setRoot('CoreMainMenuPage', { redirectPage: page, redirectParams: params }, options);
427433
}
428434

429435
/**

0 commit comments

Comments
 (0)