How do I impersonate a user with AuthLogic

Posted by Sam Saffron on Stack Overflow See other posts from Stack Overflow or by Sam Saffron
Published on 2009-08-18T10:18:15Z Indexed on 2010/04/01 18:23 UTC
Read the original article Hit count: 419

Filed under:
|
|

I need to be able to create a UserSession without having the decrypted password.

How do I go about doing this?

My current workaround is:

In user.rb

def valid_crypted_or_non_crypted_password?(password) 
   valid_password?(password) || password == crypted_password
end

In user_session.rb

verify_password_method :valid_crypted_or_non_crypted_password?

To login

UserSession.create(:login => u.login, :password => u.crypted_password)

Is there a nicer way to do this?

© Stack Overflow or respective owner

Related posts about authlogic

Related posts about ruby-on-rails