Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase redirect to webpage after successful password change

I'm using firebase in my web app with Ionic and I would like to redirect the user to a specific page (the login page, in my case) after he change the password successfully. At the moment, when the user clicks on the password reset link, he is redirected on another browser page that says that he has successfully changed the password.

enter image description here

I would like to redirect him to a page of my web app, after changing the password. Is it possible to do that?

like image 736
Lakshmi Avatar asked Jan 02 '23 03:01

Lakshmi


1 Answers

You have to pass a continue URL via ActionCodeSettings to redirect the user back to the app:

var actionCodeSettings = {
  // After password reset, the user will be give the ability to go back
  // to this page.
  url: 'https://www.example.com/afterPasswordReset',
  handleCodeInApp: false
};
firebase.auth().sendPasswordResetEmail(email, actionCodeSettings)
  .then(function() {
    // Password reset email sent.
  })
  .catch(function(error) {
    // Error occurred. Inspect error.code.
  });

Learn more about ActionCodeSettings and passing state in redirect: https://firebase.google.com/docs/auth/web/passing-state-in-email-actions

You can also build your own custom landing page here: https://firebase.google.com/docs/auth/custom-email-handler

like image 114
bojeil Avatar answered Jan 13 '23 13:01

bojeil