开发者

Sending registration verification e-mails using Authlogic?

Is there any way I can get authlogic to send email to my subscribers after they hav开发者_开发问答e registered so that they can confirm their account?


It seems like this Blogpost describes what you want to achieve.

The user model uses a perishable_token which is used for a verification url sent to the user's mail adress upon account creation. When the user clicks the url in the mail it triggers an action that sets the corresponding user model to verified

Basically you need to validate UserSessions depending on whether the corresponding User is already verified.

See:


The link suggested by Lennart is a good starting place. However a quick glance at the code reveals these caveats:

  1. Notifier#deliver_password_reset_instructions is unimplemented yet is called from User#deliver_password_reset_instructions!
  2. Notifier is a poorly named class. A Mailer generally sends notifications, so I would recommend naming the mailer class UserMailer to indicate what it is sending mail for. Also as Mailers currently reside in app/models (until Rails 3.0), appending Mailer to the class name makes it clear that it is in fact a mailer class and not an ActiveRecord model.
  3. Mailers should not be in the model. They should be in your controller actions. Ask DHH.

Good luck! Ask if you get stuck.


You can check the Ben Johnson's blog, the author of Authlogic. He has written awesome Tutorial: Reset passwords with Authlogic the RESTful way. Account confirmation is doing the same way and even less complex.


Is there any reason why you couldn't have an UserObserver (or ActivationObserver if you have multiple authentication models - e.g., admin, user, customer service rep, etc.) that sent an email out once someone is created?


You might find auth_helpers helpful. It's "a collection of modules and controller to extend your Authlogic models. Currently it supports Confirmable and Recoverable behavior."


Very late to the question but here is a template with authlogic email verification.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜