grimen / devise_facebook_connectable

Devise << Facebook Connect. IMPORTANT: Not maintained anymore.
MIT License
146 stars 20 forks source link

two models with devise :authenticatable #11

Closed bitzesty closed 14 years ago

bitzesty commented 14 years ago

I've got an admin model and an user model, the admin model does not have devise :facebook_connectable, but the user does. However when I try and login as an admin it fails with Admin undefined method facebook_connect (and the other FacebookConnectable class methods).

bitzesty commented 14 years ago

i think it was the scoping not accepting :for => :user when I was on admin/sign_in

grimen commented 14 years ago

OK, thanks, will look into this.

bitzesty commented 14 years ago

http://github.com/bitzesty/devise_facebook_connectable/commit/7ec31fc2b49e33aaa5e10fa8188987c8cbeebff2

grimen commented 14 years ago

Nested trap - is that really a best practice for warden/devise? I didn't see "pass" used in Devise authenticatable module, could you maybe elaborate on why it's needed for facebook_connectable? Feels incorrect when authenticatable is not doing this - should be same-same, right?

bitzesty commented 14 years ago

Probably not best practice anywhere, however i need to do this as this strategy is called even when a model (such as my admin model) does not have facebook_connectable. pass is just the same as do nothing and try the next strategy, which is what i want.

The better way to achieve this would be to check if the model responded to facebook_connect then just pass if it doesn't. however I needed to hack this up quick

grimen commented 14 years ago

OK, cool. Your second suggestion is most probably better. Will look on it when I get some time.

bitzesty commented 14 years ago

Warden::Strategies are stored as a hash not an array, which explains why I only occasionally hit this error, as sometimes the normal auth strategy is chosen first

bitzesty commented 14 years ago

i'm tired - it's late just looked at warden more closely and the correct place for klass.respond_to?(:facebook_connect) is in valid?

bitzesty commented 14 years ago

http://github.com/bitzesty/devise_facebook_connectable/commit/31a0b3a561ddb0b5d021a018265fa5b4dec064bf

grimen commented 14 years ago

I cannot reproduce this at all, but I posted this in Devise mailing list to be sure.

grimen commented 14 years ago

This commit "should" solve this:

http://github.com/grimen/devise_facebook_connectable/commit/77d27440b5da3ab7a9edcc209f7d92ba67bbf2fb

Can you clone, build the gem, and try in your project please? I could not re-produce so...

grimen commented 14 years ago

Hah, the reason I could not re-produce this was that I fixed the issue before I tried it. Didn't know that was the issue by then, so now I could reproduce this and the commit above fixes the issue. Now I'll bump the gem.