开发者

Confirm link creation with Ruby (on Rails)

开发者_JAVA技巧What I’d like to achieve is a typical use case: a user enters his email address into a form. After sending the form to my application an email with a random generated link should be sent out to the user which he has to click to confirm his email address. After clicking the link the address should be marked as valid in my application.

My main questions are:

  1. What is the best way to generate such random links?
  2. What is the best way to map the click on such a random link to the address in my database?

Thanks :-).


It's also provided out of the box in Devise: https://github.com/plataformatec/devise

See confirmable option.


Use AuthLogic. It does all this for you.


Like @apneadiving and @Brian pointed out you have that feature in Devise and AuthLogic, but in case you need to roll out your what better way than to learn from them:

  1. Set up a confirmations route
  2. Set up a confirmations model
  3. Set up a confirmations controller

The logic is to generate a random token (md5, sha1, whatever..) store it and send it. When your confirmations controller is called you accept the confirmation for the token passed as param.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜