Skip to content

Commit

Permalink
fix(signup): Signup screen isn't dismiss when coming back from backgr…
Browse files Browse the repository at this point in the history
…ound

Tweak of the onResume event to prevent redirection towards the signup screen when the API key

expired or isn't present

Fixes #98
  • Loading branch information
MathieuNls committed Mar 13, 2017
1 parent 4d2bdcc commit ba2acc3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule, Http } from '@angular/http';
import { Storage } from '@ionic/storage';
import { IonicStorageModule } from '@ionic/storage';
import {BrowserModule} from '@angular/platform-browser';

//Ionic Pages
Expand All @@ -22,17 +22,16 @@ import { Header } from '../components/header/header';
import { MobileError } from '../components/mobile-error/mobile-error';
import { MobileInput } from '../components/mobile-input/mobile-input';

//Common Pipes
import { TranslateModule, TranslateStaticLoader, TranslateLoader } from 'ng2-translate/ng2-translate';
import { TranslateModule, TranslateLoader, TranslateStaticLoader } from 'ng2-translate/ng2-translate';

import { TwAPIService, GAService } from 'tw-core';

import { TwCoreModule } from 'tw-core';

export function createTranslateLoader(http: Http) {
return new TranslateStaticLoader(http, './assets/i18n', '.json');
}


@NgModule({
declarations: [
MyApp,
Expand All @@ -56,6 +55,7 @@ export function createTranslateLoader(http: Http) {
ReactiveFormsModule,
BrowserModule,
HttpModule,
IonicStorageModule.forRoot(),
TranslateModule.forRoot({
provide: TranslateLoader,
useFactory: (createTranslateLoader),
Expand Down
11 changes: 8 additions & 3 deletions src/pages/login/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,13 @@ export class LogInPage extends LoginComponent{
this.loginAttempt.emit(false);
},
error => {
console.log("API Key changed");
this.loginAttempt.emit(false);
this.nav.setRoot(LogInPage);
this.loginAttempt.emit(false);

//In case the user were on the signup page, let him be
//https://github.com/Toolwatchapp/tw-mobile/issues/98
if(this.nav.getActive().name != "SignupPage"){
this.nav.setRoot(LogInPage);
}
}
);

Expand All @@ -245,6 +249,7 @@ export class LogInPage extends LoginComponent{
this.loginAttempt.emit(true);
return key;
}else{
console.log(this.nav.getActive().name)
throw new Error("No valid key");
}
});
Expand Down

0 comments on commit ba2acc3

Please sign in to comment.