Hi - if you can''t get this to work you could try building your own?
Class User
before_create :create_salt
def create_salt
unless self.salt
self.salt = random_salt
end
end
def random_salt
nums = ("0".."9").to_a
random = ""
1.upto(5) { |i| newrand << numbers[rand(numbers.size - 1)]}
return random
end
def hash_password
update_attribute :password, Digest::MD5.hexdigest("#{self.salt}#
{self.password.downcase}")
end
def password_matches? password_to_match
password == Digest::MD5.hexdigest("#{self.salt}#
{password_to_match.downcase}")
end
end
Just call hash_password after you save the user or update the password
and call password_matches? to check that the password provided is the
correct one.
Hope that helps?
On 17 Feb, 18:20, Bruno Pires
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hello all.
>
> Has anyone managed to use SaltedHashLoginGenerator with Rails 2.2.2?
>
> I''ve been following the simple steps on the README file.
>
> When I run script/generate salted_login User Localization a
> /config/environment/user_environment.rb file should be created, but
> isn''t.
>
> When I include the line: require
''environments/user_environment'' in the
> config/environment.rb file and start the server, it complains that the
> user_environment.rb file is missing.
>
> Does anyone know how to fix this?
>
> I''m using Aptana IDE with RadRails.
>
> Thanks.
>
> Bruno
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---