通过symfony2中的电子邮件链接验证用户帐户 [英] Validate user account via email link in symfony2

查看:70
本文介绍了通过symfony2中的电子邮件链接验证用户帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关如何使用symfony2进行此操作的基本说明,因为网络上没有与此相关的不错的文档。我知道如何用普通的php来完成该过程,但我不知道从symfony2开始。

I'm looking for a basic explanation of how could I do this with symfony2, since there is no decent documentation in the web about this. I know how could I do the process with plain php, but I don't know where to start with symfony2.

任何帮助,我们都将非常感谢。

Any help would be really appreciated, guys.

谢谢!

要弄清楚我要查找的内容:用户完成注册过程后,自动发送带有激活他的帐户链接的电子邮件

To clarify what I'm looking for: once the user completes the registration process, send an automatic email with a link to activate his account

推荐答案

FOSUserBundle默认具有此功能。

FOSUserBundle has this feature by default.

您可以自己执行操作:


  • 创建用户特定的安全哈希并将其存储在注册时的数据库中。

  • 向用户发送一封电子邮件,其中包含带有该哈希的链接: myapp.com/signup/token / ..(此处为令牌)... /

  • 创建到控制器的相关路由以检查哈希,将URL中的令牌作为变量传递给控制器​​。

  • 检查控制器中的哈希值是否正确,然后执行相关操作。

  • Create a user specific secure hash and store it in the database at registration.
  • Send an email to user containing a link with that hash: myapp.com/signup/token/..(token here).../
  • Create the relevant route to the controller that will check the hash, pass the token in the url to the controller as variable.
  • Check if the hash is correct in the controller and do the relevant action.

这篇关于通过symfony2中的电子邮件链接验证用户帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆