ruby on rails - How to generate reset password token -
i using devise gem authentication.
in application admin create users, want user's reset password link when admin creates users.
this action:-
def create @user = user.new(user_params) @user.password = '123123123' @user.password_confirmation = '123123123' if @user.save @user.update_attributes(:confirmation_token => nil,:confirmed_at => time.now,:reset_password_token => (0...16).map{(65+rand(26)).chr}.join,:reset_password_sent_at => time.now) usermailer.user_link(@user).deliver redirect_to users_path else render :action => "new" end end
this link reset user's password
but getting reset password token invalid when open link , update password.
you can use user.send_reset_password_instructions
that.
Comments
Post a Comment