Help understanding login logic in ionic 4 + angular

I’ve got an app that redirects users depending if they are logged in or not. It’s displaying some odd behaviour, which i’mt rying to get to the bottom of. I don’t understand the logic of this code - i am an angular newbie so it might be simple. why are there + signs in the paths, and why does it look like both times it goes to the same place. I’ve tried googling, but i’m not getting anywhere. if anyone can point me in the right direction please

  firebase.auth().onAuthStateChanged((user) => {
        console.log(user)
        if (!user) {
            return;
        }

        let providerInfo = JSON.stringify(firebase.auth().currentUser.providerData[0].providerId);

        if (Login.emailVerification && providerInfo == '"password"') {
            if (user['emailVerified']) {
                //Goto Home Page.
                this.zone.run(() => {
                    console.log("asdfsdf")
                    this.router.navigate(['/' + Login.homePage + '/' + Login.homePage + '/timeline']);

                    console.log("Go to Tabs Page")
                });
            }
            else {
                this.router.navigate(['/' + Login.verificationPage]);
            }
        }
        else {
            //Goto Home Page.
            this.zone.run(() => {
                this.router.navigate(['/' + Login.homePage + '/' + Login.homePage + '/timeline']);
                console.log("Go to Tabs Page")
            });
            //Since we're using a TabsPage an NgZone is required.
        }
    });

I’m confused. Did you not write it? Did you inherit it from somebody? If so, please ask them why they are manually dealing with zones.

No, i inherited it and unfortunately i can’t ask the old person.

My advice, copy cut paste will lead you down rabbit holes most of the time. There are numerous tutorials on login logic from beginner to advanced online. Once you understand the process, you’ll be able to develop your own login strategies.
Truth of the matter is that no one is going to start explaining code that you’ve copy pasted from elsewhere and don’t understand. First learn how to, write your own code, borrow code from someone and understand it and refactor if need be, then ask for help or advice if stuck. That way you’ll get lots of help.

1 Like

Thanks for the advice. If we realised the whole routing is wrong, so I’m going to start again and implement an auto guard as well.