An easy way to have only one step for users to confirm an email address and set an initial password using the link you offer ...
Send one message that your application generates, including reset_password_token, and consider that the user owns this token, confirming the validity of this email address.
In the system code for generating accounts, provided that the user model is configured using: recoverable and: database_authenticatable. Development Modules ...
acct = User.new acct.password = User.reset_password_token
Making reset password settings a little more understandable for users when setting the initial password.
view / testament / passwords / edit.html.erb
... <%= "true" == params[:initial] ? "Set your password" : "Reset your password" %> ...
Email Generated
Hi <%= @user.name %> An account has been generated for you. Please visit www.oursite.com/users/password/edit?initial=true&reset_password_token=<%= @user.reset_password_token %> to set your password.
No need to include: a confirmed development module in the user model, since the accounts created by your application will not be available without the reset_password_token password in the letter.
Devise will process the submission and clear the reset_password_token field.
For more information on reset_password_token methods and friends, see devise_gem_folder/lib/devise/models/recoverable.rb and database_authenticatable.rb .
If you want to use the Devise :confirmable module rather than this approach, see the quiz page .
Anatortoise House May 11 '11 at 21:30 2011-05-11 21:30
source share