Modifying the restful_authentication plugin / Classes creati

Hi,

I’m trying to modify the restful_authentication plugin so that it
first authenticates against LDAP (Active Directory), if successful, it
tries to find a matching user with the same username in the database,
through a model ‘user’. If it finds a user, it updates a last_login
attribute; if it doesn’t find one, it creates one. The “remember me”
functionality is also incorporated.

I have incorporated these changes into the sessions controller and
that is all working fine but I don’t know how to incorporate them into
the authenticated_system module. Basically the authenticated_system.

I suppose my question really is: Is it okay for a model class to
create an instance of itself in a class method? As this is the only
way I can think of keeping the http authentication that is offered by
restful_authentication.

Thanks,
Toby

Hi,

I’m trying to modify the restful_authentication plugin so that it
first authenticates against LDAP (Active Directory), if successful, it
tries to find a matching user with the same username in the database,
through a model ‘user’. If it finds a user, it updates a last_login
attribute; if it doesn’t find one, it creates one. The “remember me”
functionality is also incorporated.

I do something similar and didn’t have to change
lib/authenticated_system.rb.

I first check an external database that has authentication information.

If authentication is successful and this user does not already exist
locally I copy the authentication tokens and the rest of the user
attributes I am interested in to my local user model.

If I can’t connect to the external database I authenticate to my local
User model.

This is all done with modifications to the User model. You can see the
code here:

svn.concord.org/svn/teemss2/branches/teemss2diy-plus-sail/app/models/user.rb

Look at the code that starts with this method:

Authenticates a user by their login name and unencrypted password.

Returns the user or nil.
def self.authenticate(identifier, password)
user = User.remote_authenticate(identifier, password)
user || local_authenticate(identifier, password)
end

That’s great thanks. My question was really vague and you still
managed to answer it perfectly!

On Aug 5, 12:52 am, Stephen B. [email protected]