Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Authlogic to authenticate with only a username

There's this mother app which is on Java (Struts), which also handles authentication. My Rails app which is being integrated into the mother app uses authlogic. Ofcourse, the requirement is, once someone logs into the mother app, they should automatically be able to access my Rails app without signing in again.

Is there any way, by using just the user id , I can authenticate the user using Authlogic?

I removed my password column in my Users table and stuck this piece of code into the User model.

acts_as_authentic do |config|
  config.check_passwords_against_database = false
  config.validate_password_field = false
  config.crypted_password_field = false
end

But I'm still not able to do what I wanted to do.I get an error indicating that the password can't be blank.Help would be appreciated! Thanks.

like image 603
Shreyas Avatar asked Sep 13 '10 08:09

Shreyas


1 Answers

Just pass a user object instead of login/password

UserSession.new(User.find_by_username('Shreyas Satish'))

(This works with rails 3 and authlogic 2.1.6)

like image 84
fantactuka Avatar answered Sep 29 '22 08:09

fantactuka