If you are using a one way hash, like 'digest/sha1', then you will not be able to decrypt the password. You can only reset it to something the system knows then send that password to them.
On Tue, Feb 9, 2010 at 6:54 AM, RubyonRails_newbie <[email protected]> wrote: > When I amended my registration page, I included the digest to encrypt > the password in the database. > > If someone forgets their password, how do I get this mailed back to > the user? > > The action is as follows: > > > > def remind > > �...@title = "Remind Me!" > > if param_posted?(:user) > > email = params[:user][:email] > > user = User.find_by_email(email) > > If user > > UserMailer.deliver_reminder(@user) > > flash[:notice] = "Reminder sent." > > redirect_to :action => "index", :controller => "site" > > else > > flash[:notice] = "There is no user with that email > address." > > end > > end > > end > > This then calls the reminder part of UserMailer.deliver and sends the > user their username and password. > > This template shows… Hello, You have just requested your login > details. Please see below: > > > Username: <%= @user.username % > > Password: <%= @user.password %> > > Thing is, with the password, as-is, it just prints the encrypted > string, so is no use to a user. > > AT the moment I only mail out the username, as the password at the > moment isn’t helpful. > > Is there a way to decrypt for the purposes of reminding someone? > > Many Thanks... :-) > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- Curtis Cooley [email protected] home:http://curtiscooley.com blog:http://ponderingobjectorienteddesign.blogspot.com =============== Leadership is a potent combination of strategy and character. But if you must be without one, be without the strategy. -- H. Norman Schwarzkopf -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

