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 UserSession
s 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:
Notifier#deliver_password_reset_instructions
is unimplemented yet is called fromUser#deliver_password_reset_instructions!
- 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.
- 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.
精彩评论