How can I impersonate a user using AuthLogic

I need to create a UserSession without a decrypted password.

How can I do it?

My current workaround:

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? 

Login

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

Is there a better way to do this?

+6
ruby ruby-on-rails authlogic
source share
1 answer

According to the documentation, you can pass the user object UserSession.create .

 UserSession.create(@some_user) 

I have not tried it yet.

+11
source share

All Articles