1
I’m trying to validate the login, but is passing straight through and entering the home, I don’t know what could be going on:
import { Component } from '@angular/core';
import {LoginPage} from '../login/login';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
window.localStorage.removeItem('currentuser');
if(this.isLoggedin()){
console.log('you are not logged in');
this.navCtrl.push(LoginPage);
}
}
isLoggedin(){
if(window.localStorage.getItem('currentuser')){
return true;
}
}
}
And if you put
if(window.localStorage.getItem('currentuser')){
 return true;
 } else { return false;}
– viana
The result is the same
– leoSandrini
Your logic is: If there is an item on the site.Log, return true. If not, return false. Right?! At the moment there is something in the saved currentuser?
– viana
Are you using Ionic 1 or 2?
– viana
Ionic 2. With the exclamation mark, it worked, thank you!
– leoSandrini
I removed the Ionic tag and left only Ionic 2.
– viana