简体   繁体   English

Auth0:让用户重新发送验证电子邮件

[英]Auth0: Let user resend the Verification Email

I enabled the user/password connection in Auth0, and I would like to have the emails verified before proceeding.我在 Auth0 中启用了用户/密码连接,我希望在继续之前验证电子邮件。 I enabled the corresponding rule to force the email verification and everything seems to work as expected.我启用了相应的规则来强制电子邮件验证,一切似乎都按预期工作。

Still, I noticed that the verification email is sent upon signing up.不过,我注意到在注册时发送了验证电子邮件。 I want a button to allow sending that email again, but this doesn't seems to be possible.我想要一个按钮来允许再次发送该电子邮件,但这似乎不可能。

How can a user, from the UI, ask for a verification email?用户如何从 UI 请求验证电子邮件?

Calling https://<tenantName>.auth0.com/api/v2/jobs/verification-email won't do, because the token needs the update:users scope.调用https://<tenantName>.auth0.com/api/v2/jobs/verification-email不起作用,因为令牌需要update:users范围。 We can get a token with that scope with a request to https://<tenantName>.auth0.com/oauth/token , but that means the client secret would be exposed.我们可以通过向https://<tenantName>.auth0.com/oauth/token发出请求来获取具有该范围的https://<tenantName>.auth0.com/oauth/token ,但这意味着客户端机密将被公开。

there is a work around for this, I use it as a post email verification signal.对此有一个解决方法,我将其用作邮件后验证信号。 auth0 create a ticket and send us a link with the ticket id as query string to verify the email, the link sent is like below: auth0 创建一个票证并向我们​​发送一个带有票证 ID 作为查询字符串的链接以验证电子邮件,发送的链接如下所示:

https://<domain>/u/email-verification?ticket=h7CtBxPXiej7FtaKo0UHYJtdWPazaHhs#

you can use this api to resend the email verfication link, here is an example of the request:您可以使用此 api 重新发送电子邮件验证链接,这是请求的示例:

curl --location --request POST 'https://<domain>/api/v2/tickets/email-verification' \
--header 'Authorization: Bearer <token> \
--header 'Content-Type: application/json' \
--header 'Cookie: __cfduid=d7aa37a65221ad2c0fd17ec71c76f13eb1603727648; did=s%3Av0%3A694d6590-1a83-11eb-877d-d1f701a6b5e1.qweiCQT%2Fah2JbVlHe8mU7En5egRFtrEmjETM%2B%2BIKmzc; did_compat=s%3Av0%3A694d6590-1a83-11eb-877d-d1f701a6b5e1.qweiCQT%2Fah2JbVlHe8mU7En5egRFtrEmjETM%2B%2BIKmzc' \
--data-raw '{
  "result_url": "<redirection_url>",
  "user_id": <auth0_user_id>,
  "ttl_sec": 0,
  "includeEmailInRedirect": false,
  "identity": {
    "user_id": "<user_id>",
    "provider": "auth0"
  }
}'

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

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