Mehtod not found with single Access Token

42 views
Skip to first unread message

dalboy

unread,
Apr 23, 2009, 6:03:24 PM4/23/09
to Authlogic
I want to enable the single access token for my site and change it
from the default. This is how I understand to set the configuration

class User < ActiveRecord::Base
acts_as_authentic do |c|
c.single_access_allowed_request_types = :all
end
end

but I get a method not found error

undefined method `single_access_allowed_request_types='

What am I doing wrong? Authlogic is installed as a plugin.

Cheers

Dalboy

Ben Johnson

unread,
Apr 23, 2009, 6:04:19 PM4/23/09
to auth...@googlegroups.com
Actually that configuration should be called in your UserSession, not
the user model.



Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

1430 Broadway
7th Floor - NECO
New York, NY 10018

dalboy

unread,
Apr 23, 2009, 6:44:31 PM4/23/09
to Authlogic
Should it be In the userSession Controller?

Something like this

def new
@user_session = UserSession.new
@user_session.single_access_allowed_request_types => :all
end

Thanks for your help.

On Apr 23, 11:04 pm, Ben Johnson <bjohn...@binarylogic.com> wrote:
> Actually that configuration should be called in your UserSession, not  
> the user model.
>
> Ben Johnson
> Binary Logic
>
> W:www.binarylogic.com
> E: bjohn...@binarylogic.com

Ben Johnson

unread,
Apr 23, 2009, 6:45:24 PM4/23/09
to auth...@googlegroups.com
no, in your user session model:

class UserSession < Authlogic::Session::Base
single_access_allowed_request_types = :all
end



Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

1430 Broadway
7th Floor - NECO
New York, NY 10018

dalboy

unread,
Apr 23, 2009, 7:42:45 PM4/23/09
to Authlogic
Hi Ben

Thanks for your assistance. I added it to the model and this stopped
the Method not found errors as would be expected when you have it in
the right place.

Alas, the single token access was still not working. I had a dig
around in params.rb and noticed that it is checking with an includes?
method. The single access token did work if I appended the request
type.

single_access_allowed_request_types << :all

Is this what you would expect? should the = work?

On Apr 23, 11:45 pm, Ben Johnson <bjohn...@binarylogic.com> wrote:
> no, in your user session model:
>
> class UserSession < Authlogic::Session::Base
> single_access_allowed_request_types = :all
> end
>
> Ben Johnson
> Binary Logic
>
> W:www.binarylogic.com

Ben Johnson

unread,
Apr 23, 2009, 7:57:54 PM4/23/09
to auth...@googlegroups.com
That should work but not what I was expecting. I just pushed a change
to the repo, you should be able to just set it to :all if you update
from the repo.

Good find.



Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

1430 Broadway
7th Floor - NECO
New York, NY 10018

dalboy

unread,
Apr 23, 2009, 8:58:54 PM4/23/09
to Authlogic
I grabbed the changes and can see where you are checking if it is
equal to :all. However, I don't think
single_access_allowed_request_types is being changed when you use = to
assign the request type.



On Apr 24, 12:57 am, Ben Johnson <bjohn...@binarylogic.com> wrote:
> That should work but not what I was expecting. I just pushed a change  
> to the repo, you should be able to just set it to :all if you update  
> from the repo.
>
> Good find.
>
> Ben Johnson
> Binary Logic
>
> W:www.binarylogic.com

Ben Johnson

unread,
Apr 23, 2009, 9:46:40 PM4/23/09
to auth...@googlegroups.com
It is:

def test_single_access_allowed_request_types
UserSession.single_access_allowed_request_types = ["my
request type"]
assert_equal ["my request type"],
UserSession.single_access_allowed_request_types

UserSession.single_access_allowed_request_types ["application/
rss+xml", "application/atom+xml"]
assert_equal ["application/rss+xml", "application/atom+xml"],
UserSession.single_access_allowed_request_types
end

I am testing it with passing tests.



Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

1430 Broadway
7th Floor - NECO
New York, NY 10018

dalboy

unread,
Apr 23, 2009, 10:28:36 PM4/23/09
to Authlogic
In that case I must still not have the config value correct in the
userSession model. changing it to

self.single_access_allowed_request_types = :all

seems to have fixed it, and the value is being set now. Is this what
it should be?

However, setting it to :all causes this error

undefined method `include?' for :all:Symbol

This is going to happen for

(single_access_allowed_request_types.include?
(controller.request_content_type)
and
single_access_allowed_request_types.include?(:all)

in the params_enabled? method in params.rb


On Apr 24, 2:46 am, Ben Johnson <bjohn...@binarylogic.com> wrote:
> It is:
>
> def test_single_access_allowed_request_types
>          UserSession.single_access_allowed_request_types = ["my  
> request type"]
>          assert_equal ["my request type"],  
> UserSession.single_access_allowed_request_types
>
>          UserSession.single_access_allowed_request_types ["application/
> rss+xml", "application/atom+xml"]
>          assert_equal ["application/rss+xml", "application/atom+xml"],  
> UserSession.single_access_allowed_request_types
>        end
>
> I am testing it with passing tests.
>
> Ben Johnson
> Binary Logic
>
> W:www.binarylogic.com

Ben Johnson

unread,
Apr 23, 2009, 10:38:12 PM4/23/09
to auth...@googlegroups.com
Sorry about that, update from the repo one more time, this should take
care of it.



Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

1430 Broadway
7th Floor - NECO
New York, NY 10018

dalboy

unread,
Apr 24, 2009, 10:00:31 AM4/24/09
to Authlogic
Thanks Ben. All working now. The single access token functionality is
a great feature of Authlogic, it's very useful.

On Apr 24, 3:38 am, Ben Johnson <bjohn...@binarylogic.com> wrote:
> Sorry about that, update from the repo one more time, this should take  
> care of it.
>
> Ben Johnson
> Binary Logic
>
> W:www.binarylogic.com
Reply all
Reply to author
Forward
0 new messages