Using Authlogic to authenticate with only a username

ぃ、小莉子 提交于 2019-12-23 10:20:10

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/3698988/using-authlogic-to-authenticate-with-only-a-username

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!