@Jester12 wrote:
I’m confused on how to redirect user while on login
Scenario:
-> After filling up login details and submitting, the user is redirected to an examination test. After Filling it up, the user will now then be redirected to the home page. When the user decides to log out, and then login back again, the user must be redirected to the home page.
I’m planning on my
auth.ts
, upon the first login, on my firebase, I will set a checker like 1’s(If user is done with the test) and 0’s (If user is not done with the test)User |_UID |_Checker:"1/0" // Either 1 or 0
Below is the code for the Login:
loginUser() { if (!this.loginForm.valid) { console.log(this.loginForm.value); } else { this.authData.loginUser(this.loginForm.value.email, this.loginForm.value.password) .then(authData => { //if user is done with the test this.navCtrl.push(HomePage); //else this.navCtrl.push(TestPage); }, error => { this.loading.dismiss().then(() => { let alert = this.alertCtrl.create({ message: error.message, buttons: [ { text: "Ok", role: 'Cancel' } ] }); alert.present(); }); })
Auth.ts
loginUser(newEmail: string, newPassword: string): firebase.Promise<any> { return this.afAuth.auth.signInWithEmailAndPassword(newEmail, newPassword) .then(newUser => { const x = this.afAuth.auth.currentUser.uid; if (x != null) { firebase.database().ref('/Users').child(newUser.uid).set({ email: newEmail, }) } else { firebase.database().ref('/Users').child(newUser.uid) } })}
Posts: 2
Participants: 2