I am creating an application for which I am trying to use LDAP with authlogic for login authentication. I want to accept just the username and log the user in if he is on the LDAP server. For this, I need to disable the password validation. How can I do that?
views:
331answers:
3
A:
I was successful doing this with Open ID (same idea, password not stored by my app) by not having a password column in the users
table and using this config for Authlogic:
class User < ActiveRecord::Base
acts_as_authentic do |c|
c.crypted_password_field = false
end
end
Without setting crypted_password_field
, there were errors generated during user saves.
Sean Carpenter
2010-01-03 19:01:30
I tried it but it didn't work for me. Prior to this I used authlogic-openid gem to create a login which doesn't require password.I refered to this screencast: http://railscasts.com/episodes/160-authlogic
chetu
2010-01-05 00:41:14
What didn't work? Were there errors generated?
Sean Carpenter
2010-01-05 14:19:50
It still says "Password can not be blank" even though I didn't provide a password field on the UI.
chetu
2010-01-06 18:37:01
You need to make sure there is no password field in the `users` table (or whatever table underlies your `acts_as_authentic` model). This is what generates a password attribute on the model.
Sean Carpenter
2010-01-06 19:22:13
My user model doesn't have password field but still it gives me the same error message. I feel like password is required in authlogic gem.
chetu
2010-01-15 04:28:32
+1
A:
In your User model where you call acts_as_authentic, this might do the trick:
acts_as_authentic do |config|
config.require_password_confirmation = false
config.ignore_blank_passwords = true
end
These config options, among others, can be found in lib/authlogic/acts_as_authentic/password.rb (in version 2.1.3).
Eliot Sykes
2010-01-26 07:19:28
I tried that too but didn't work. I looked in the source code for authlogic and it looks like UserSession model still needs password when it tries to save it.
chetu
2010-02-01 16:51:53
A:
I think you can do it like this:
class User < ActiveRecord::Base
acts_as_authentic do |config|
config.validate_password_field = false
end
end
J. Pablo Fernández
2010-04-03 23:29:33