简体   繁体   English

Firebase 验证和重置密码,无需发送单独的邮件

[英]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.从以下文档中,我可以看到有一个名为 mode 的参数来标识操作。 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).我能想到的一种解决方法是使用 continueUrl (可能使用自定义方案)。 Not sure if this will work flawlessly.不确定这是否会完美运行。

Can somebody share their thoughts on this.有人可以分享他们对此的想法。

Using the continueUrl is indeed the correct way.使用continueUrl确实是正确的方法。 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.根据mode ,您可以决定要处理的操作,然后您可以在用户执行相应操作后重定向到continueUrl

For example, the documentation you refer to shows the following example (note the // TODO: If a continue URL is available... comment):例如,您参考的文档显示了以下示例(注意// TODO: If a continue URL is available...注释):

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.
  });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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