Using authlogic With a Model Other Than User?

Hello,

I want to implement authentication using the authlogic gem in an
application that already implements a User model that I cannot
modify. The authlogic authentication would be for something like a
new AdminUser model, completely separate from the existing User model.

Since authlogic is installed as a gem on the server (and used by other
applications), the gem code itself cannot be modified.

Any tips for where to begin/how to approach this?

thanks.

This sounds like a bad idea, however, you can pack the gems (move them
into the vendor directory) and modify them there. If you have to make
significant changes, you can always fork the code and create your own
gem.

Darian Shimy

Quoting athem <allan.m.miller@gmail.com>:

Hello,

I want to implement authentication using the authlogic gem in an
application that already implements a User model that I cannot
modify. The authlogic authentication would be for something like a
new AdminUser model, completely separate from the existing User model.

Since authlogic is installed as a gem on the server (and used by other
applications), the gem code itself cannot be modified.

Any tips for where to begin/how to approach this?

What happens if you just add acts_as_authenticated to the AdminUser model? It
may take a little monkeying about to discover what AuthLogic is expecting the
other pieces to be named, like sessions. Give it a try. And report back here
on the list for the future.

Jeffrey

Maybe a stupid question here, but could you not make AdminUser a
subclass of User and turn off the authlogic on User methods? I guess
what I'm asking here is are there certain design requirements in your
project which dictate that the AdminUser class *must* be separated
from the base User class?

It seems that if the AdminUser needs to be separate — and you need to
user authlogic — the logical choice would be to fork the gem and make
your modifications to that copy instead of monkeying around in the
official gem. It may also be easier to just add access control to the
existing User class which allows certain users to be Admins.

Just trying to wrap my head around this. :slight_smile: