Commit f8c24bf813deead94b3bac788def6db4d9d9a1ae
1 parent
401a2773
Exists in
master
and in
29 other branches
Add support for salted_md5 passwords
Showing
2 changed files
with
10 additions
and
0 deletions
Show diff stats
app/models/user.rb
... | ... | @@ -201,6 +201,10 @@ class User < ActiveRecord::Base |
201 | 201 | Digest::MD5.hexdigest(password) |
202 | 202 | end |
203 | 203 | |
204 | + add_encryption_method :salted_md5 do |password, salt| | |
205 | + Digest::MD5.hexdigest(password+salt) | |
206 | + end | |
207 | + | |
204 | 208 | add_encryption_method :clear do |password, salt| |
205 | 209 | password |
206 | 210 | end | ... | ... |
test/unit/user_test.rb
... | ... | @@ -190,6 +190,12 @@ class UserTest < ActiveSupport::TestCase |
190 | 190 | assert_equal '098f6bcd4621d373cade4e832627b4f6', user.crypted_password |
191 | 191 | end |
192 | 192 | |
193 | + | |
194 | + def test_should_support_salted_md5_passwords | |
195 | + user = new_user(:login => 'lalala', :email => 'lalala@example.com', :password => 'test', :password_confirmation => 'test', :password_type => 'salted_md5', :salt => 'test') | |
196 | + assert_equal '05a671c66aefea124cc08b76ea6d30bb', user.crypted_password | |
197 | + end | |
198 | + | |
193 | 199 | def test_should_support_crypt_passwords |
194 | 200 | user = new_user(:login => 'lalala', :email => 'lalala@example.com', :password => 'test', :password_confirmation => 'test', :password_type => 'crypt', :salt => 'test') |
195 | 201 | assert_equal 'teH0wLIpW0gyQ', user.crypted_password | ... | ... |