简体   繁体   中英

Firebase verify and reset password without sending separate mails

As part of offline user creation, I wanted to create an account from my back-end server and send out verification mail to user. But when user clicks on the verification link, I also want to present a screen to set his password.

In the existing web-app, I have individual flows to handle verify and reset-password. but they are separate flows.

From the following doc I could see that there is a parameter called mode to identify the action. Using this we are currently handling the verify and reset-password actions.

But is there a way to have a custom mode or some means to identify that the user has to be taken to a different screen after verification.

One workaround I can think of is to use the continueUrl (may be with a custom scheme). Not sure if this will work flawlessly.

Can somebody share their thoughts on this.

Using the continueUrl is indeed the correct way. Based on the mode you can decide which action is to be treated and then you can redirect to the continueUrl after the user has executed the corresponding action.

For example, the documentation you refer to shows the following example (note the // TODO: If a continue URL is available... comment):

function handleVerifyEmail(auth, actionCode, continueUrl, lang) {
  // Localize the UI to the selected language as determined by the lang
  // parameter.
  // Try to apply the email verification code.
  auth.applyActionCode(actionCode).then(function(resp) {
    // Email address has been verified.

    // TODO: Display a confirmation message to the user.
    // You could also provide the user with a link back to the app.

    // TODO: If a continue URL is available, display a button which on
    // click redirects the user back to the app via continueUrl with
    // additional state determined from that URL's parameters.
  }).catch(function(error) {
    // Code is invalid or expired. Ask the user to verify their email address
    // again.
  });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM