cschiewek/devise_ldap_authenticatable — pull request #152 by aaronklaassen (2013-12-12 15:08:39+00:00)
Title: Devise Lockable compatibility

Because #authenticate_with_ldap returns nil when the authentication fails, Devise's Lockable module wouldn't work: the failed_attempts attribute is incremented when the resource is validated, which can't happen to a nil resource, obviously.

I changed #authenticate_with_ldap to #find_for_ldap_authentication. This matches the pattern in database_authenticatable, and returns a resource regardless of whether the user is authenticated or not (but only creates it locally when the correct password is supplied).

#validate gets passed a block to do the password check for actual login, just like database_authenticatable. And, of course, lockable works.