Use Model Other Than Users

43 views
Skip to first unread message

Karl

unread,
Dec 16, 2009, 1:04:09 PM12/16/09
to Authlogic
I would like to use authlogic in my existing app that does not have
authentication. But my users are in a model called CaseWorker.

This did not work:

class CaseWorker < ActiveRecord::Base
acts_as_authentic do |c|
c.session_class = 'UserSession'
end
end

How do I get authlogic to work with a User model named CaseWorker?

Jared Fine

unread,
Dec 17, 2009, 10:14:49 AM12/17/09
to auth...@googlegroups.com
Something like this should work.

class CaseWorker < ActiveRecord::Base
 acts_as_authentic do |c|
   c.session_class = 'Session'
 end
end

class Session < Authlogic::Session::Base
  authenticate_with CaseWorker
end


--

You received this message because you are subscribed to the Google Groups "Authlogic" group.
To post to this group, send email to auth...@googlegroups.com.
To unsubscribe from this group, send email to authlogic+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/authlogic?hl=en.



Karl

unread,
Dec 17, 2009, 2:19:20 PM12/17/09
to Authlogic
authenticate_with... that's the ticket.

Thanks.

> > authlogic+...@googlegroups.com<authlogic%2Bunsubscribe@googlegroups .com>

Jared Fine

unread,
Dec 17, 2009, 2:21:46 PM12/17/09
to auth...@googlegroups.com
No prob, I'm not sure session_class is needed. Though it probably couldn't hurt. One thing to note is that it should be c.session_class = Session as session_class accepts a class not a string.

Cheers.

To unsubscribe from this group, send email to authlogic+...@googlegroups.com.

Karl

unread,
Dec 18, 2009, 11:51:26 AM12/18/09
to Authlogic
On Dec 17, 12:21 pm, Jared Fine <ja...@jfine.org> wrote:
> No prob, I'm not sure session_class is needed. Though it probably couldn't
> hurt. One thing to note is that it should be c.session_class = Session as
> session_class accepts a class not a string.

It is not needed. My session class is UserSession, and it works just
fine with c.session_class.

And you are correct, it takes a class parameter.

Reply all
Reply to author
Forward
0 new messages