Logged-in verification on Ionic

Discussão em 'Angular' iniciado por Samuel Freitas, Novembro 6, 2024.

  1. I'm trying to use ngOnInit to verify if a value is set on the app's localStorage, but it doesn't work.

    this is what i have now:

    this is the function that logs the user in the app

    async login() {
    try {
    await this.authService.SignUpWithEmail(this.email, this.password);
    await this.router.navigate(['secundaria']);
    localStorage.setItem("logged-status", "logged-in")
    }


    this is what verify if the value is in the local storage

    ngOnInit() {
    if (localStorage.getItem("logged-in" ) !== null) {
    this.navCtrl.navigateForward(["quarta"])
    }
    }


    It seems like the app isn't running the code, since it doesn't work at all.

    Can someone help me? I'm trying to do this for an hour now and it doesn't work

    Continue reading...

Compartilhe esta Página