[Rails] Setting passwords for users (Login Generator)

Stian Grytøyr sgrytoyr at gmail.com
Sat Feb 26 18:10:19 GMT 2005


Nickolay Kolev <nmkolev at uni-bonn.de> wrote:

> insert into users (login, password) values ('myname', sha1('mypass'));
> 
> The row gets inserted properly, but when trying to login as the new
> user the login is rejected?

You didn't include the "salt" string (from user.rb):

Digest::SHA1.hexdigest("change-me--#{pass}--")

An even better approach would be to combine the username and
password into a single string before running sha1 on it, so that two
users with the same password will generate different hashes.

-- 
Regards,
Stian Grytøyr


More information about the Rails mailing list