kalasjocke / authlogic-facebook-connect Goto Github PK
View Code? Open in Web Editor NEWFacebook Connect for Authlogic
Facebook Connect for Authlogic
If one places <%= authlogic_facebook_login_button %> inside the form_for, things will almost work but not quite.
If it's easy to do, it would be nice if it worked one way or another.
Otherwise it might be worth specifying more precisely where to put the authlogic_facebook_login_button in the instructions.
Thanks!
When a new user clicks the Facebook login button, the popup shows. But after pressing "allow" the user is not redirected to the dashboard page. However, after this, if the user refreshes the login page and clicks the Facebook login button again, he is immediately taken to the dashboard (the url bar shows that it first goes to /user_session for authentication - and there is no popup because the application is allowed.)
Hi,
Is this plugin Rails 3 compatible?
I have tried using it in a sample app - https://github.com/kimptoc/Authlogic-Scratch/commits/authlogic_facebook_connect
But the authlogic_facebook_login_button tag is returning html encoded html - eg < ... rather than < .
Thanks,
Chris
The authlogic_facebook_login_button
method accepts a "js" option which supports prototype, and jquery libraries. The JavaScript part of this function simply gets an element by id, and calls the submit method on it. It will be nice to make it library independent by simply replacing various library specific implementations such as:
$('connect_to_facebook_form')
jQuery('#connect_to_facebook_form')
with
document.getElementById('connect_to_facebook_form')
The above method is cross-browser and works on all browsers as fari as I know. We wouldn't have to keep adding support for each individual library with this change. The file that the change would need to go in is authlogic_facebook_connect/helper.rb
is it possible to pass the authlogic helper a string that it will render as a link? such as with the facebook api: <fb:login-button v="2">fb:intlMy custom text here/fb:intl/fb:login-button
can this be achieved with authlogic facebook connect?
thanks,
plc
Setting facebook_valid_user to true causes self.attempted_record.valid?
to get called but it doesn't actually save the record anywhere...
At first, I don't know where you resolve in normal cases. But I found this bug when I logged to site with facebook_connect and then recreate database. So I found exception. I dive deeper to your library and found that you have infinity callback calling in line:
validate :validate_by_facebook_connect, :if => :authenticating_with_facebook_connect?
and you call save in validate_by_facebook_connect, so it recursivly call itself. I fix it by this code:
def validate_by_facebook_connect
facebook_session = controller.facebook_session
self.attempted_record = facebook_user_class.find(:first, :conditions => { facebook_uid_field => facebook_session.user.uid })
if self.attempted_record
self.attempted_record.update_attribute(facebook_session_key_field, facebook_session.session_key)
end
Please add fix in new version
Hi Joakim -
I added this to the session.rb file (line 75)
Facebooker::User::STANDARD_FIELDS.each do |f|
if new_user.respond_to?(f)
new_user[f] = facebook_session.user.send(f)
end
end
If the user model has fields with the same names, e.g. first_name it will populate the record when it creates it.
Hi everyone,
I'm encountering a curious bug since a week or so now.
This example: big-glow-mama.heroku.com has exactly the same issue as me.
In order to get logged in you have to click the login button, click allow, then the website is rendered inside of the popup without logging you in, you then have to close the popup, refresh the website and hit loggin button again.
The url of the page in the popup looks like this
[http://dev.local.com/?perms=email%2Cuser_birthday%2Cuser_location%2Cread_friendlists&selected_profiles=64...501&installed=1&session=%7B%22session_key%22%3A%222..........g7PfgULSyg__.3600.1283871600-642582501%22%2C%22uid%22%3A642582501%2C%22expires%22%3A1283871600%2C%22secret%22%3A%22egz4Inb...........__%22%2C%22sig%22%3A%22917cf28.....4f9dda6758......ba1357%22%7D]
I also managed to get it working without extended permissions but as soon as I add extended permissions it fails. The weird part is that the example linked above doesn't request extended permissions.
I'm completely lost and don't know how to solve this.
Once the user is authenticated using the Connect button, I get this error any time authlogic tries to validate the session:
undefined method `user' for #User:0x7f1b215fc5b0
in:
/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:260:in method_missing' /vendor/plugins/authlogic_facebook_connect/lib/authlogic_facebook_connect/session.rb:80:in
try'
/vendor/plugins/authlogic_facebook_connect/lib/authlogic_facebook_connect/session.rb:80:in `validate_by_facebook_connect'
I think the problem is with this line:
self.attempted_record = facebook_user_class.find(:first, :conditions => { facebook_uid_field => facebook_session.user.uid }).try(:"#{klass}".to_s.underscore)
It looks strange, it basically does "User.find(...).user" so it fails.
after installing the authlogic_facebook_connect plugin, the oauth login with Twitter method no longer works. the error originates at authlogic_facebook_connect/lib/authlogic_facebook_connect/session.rb:132:in `authenticating_with_facebook_connect?'
here's the error:
NoMethodError in User sessionsController#create
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.+
here's the stack trace:
/opt/local/lib/ruby/gems/1.8/gems/facebooker-1.0.67/lib/facebooker/rails/controller.rb:125:in fb_cookie_prefix' /opt/local/lib/ruby/gems/1.8/gems/facebooker-1.0.67/lib/facebooker/rails/controller.rb:129:in
fb_cookie_names'
/opt/local/lib/ruby/gems/1.8/gems/facebooker-1.0.67/lib/facebooker/rails/controller.rb:129:in select' /opt/local/lib/ruby/gems/1.8/gems/facebooker-1.0.67/lib/facebooker/rails/controller.rb:129:in
fb_cookie_names'
/opt/local/lib/ruby/gems/1.8/gems/facebooker-1.0.67/lib/facebooker/rails/controller.rb:135:in secure_with_cookies!' /opt/local/lib/ruby/gems/1.8/gems/facebooker-1.0.67/lib/facebooker/rails/controller.rb:30:in
create_facebook_session'
/opt/local/lib/ruby/gems/1.8/gems/facebooker-1.0.67/lib/facebooker/rails/controller.rb:44:in set_facebook_session' /opt/local/lib/ruby/gems/1.8/gems/authlogic-2.1.3/lib/authlogic/controller_adapters/abstract_adapter.rb:63:in
send'
/opt/local/lib/ruby/gems/1.8/gems/authlogic-2.1.3/lib/authlogic/controller_adapters/abstract_adapter.rb:63:in method_missing' path_to_my_app/vendor/plugins/authlogic_facebook_connect/lib/authlogic_facebook_connect/session.rb:132:in
authenticating_with_facebook_connect?'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in send' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in
evaluate_method'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:195:in should_run_callback?' /opt/local/lib/ruby/gems/1.8/gems/authlogic-2.1.3/lib/authlogic/session/password.rb:127:in
all?'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:195:in each' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:195:in
all?'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:195:in should_run_callback?' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:166:in
call'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:93:in run' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in
each'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in send' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in
run'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:276:in run_callbacks' /opt/local/lib/ruby/gems/1.8/gems/authlogic-2.1.3/lib/authlogic/session/callbacks.rb:72:in
validate'
/opt/local/lib/ruby/gems/1.8/gems/authlogic-2.1.3/lib/authlogic/session/validation.rb:64:in valid?' /opt/local/lib/ruby/gems/1.8/gems/authlogic-2.1.3/lib/authlogic/session/existence.rb:65:in
save'
/opt/local/lib/ruby/gems/1.8/gems/authlogic-oauth-1.0.8/lib/authlogic_oauth/session.rb:46:in save' path_to_my_app/app/controllers/user_sessions_controller.rb:15:in
create'
any suggestions?
e.g. facebook_skip_new_user_creation = true - where do you put this line?
It doesn't work in the regular acts_as_authentic block, and it doesn't work in the UserSession object.
Where should it go?
I was having problems with this fantastic addon and PostgreSQL, so I made some little fixes to the queries to make them work nicely with PostgreSQL
Thank you :)
I get this error when try to login with Facebook connect.
Either problem in example rails app.
Here is application trace:
/home/scream3/Temp/authlogic_example/vendor/plugins/authlogic_facebook_connect/lib/authlogic_facebook_connect/session.rb:37:in `facebook_uid_field'
/home/scream3/Temp/authlogic_example/vendor/plugins/authlogic_facebook_connect/lib/authlogic_facebook_connect/session.rb:99:in `facebook_uid_field'
/home/scream3/Temp/authlogic_example/vendor/plugins/authlogic_facebook_connect/lib/authlogic_facebook_connect/session.rb:59:in `validate_by_facebook_connect'
/home/scream3/Temp/authlogic_example/vendor/rails/activesupport/lib/active_support/callbacks.rb:178:in `send'
/home/scream3/Temp/authlogic_example/vendor/rails/activesupport/lib/active_support/callbacks.rb:178:in `evaluate_method'
/home/scream3/Temp/authlogic_example/vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in `call'
/home/scream3/Temp/authlogic_example/vendor/rails/activesupport/lib/active_support/callbacks.rb:93:in `run'
/home/scream3/Temp/authlogic_example/vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in `each'
/home/scream3/Temp/authlogic_example/vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in `send'
/home/scream3/Temp/authlogic_example/vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in `run'
/home/scream3/Temp/authlogic_example/vendor/rails/activesupport/lib/active_support/callbacks.rb:276:in `run_callbacks'
/usr/lib/ruby/gems/1.8/gems/authlogic-2.0.11/lib/authlogic/session/callbacks.rb:71:in `validate'
/usr/lib/ruby/gems/1.8/gems/authlogic-2.0.11/lib/authlogic/session/validation.rb:58:in `valid?'
/usr/lib/ruby/gems/1.8/gems/authlogic-2.0.11/lib/authlogic/session/existence.rb:63:in `save'
/home/scream3/Temp/authlogic_example/app/controllers/user_sessions_controller.rb:11:in `create'
Using the most recent version, with the session_key field added by David Li.
After a user authenticates with facebook (in the popup window), facebook redirects them to mysite.com/user_sessions, where this error is thrown:
user_sessions#create (NameError) "undefined local variable or method `new_user' for #"
And here's the end of the backtrace:
/home/mysite/releases/20091202235230/vendor/plugins/authlogic_facebook_connect/lib/authlogic_facebook_connect/session.rb:102:in `validate_by_facebook_connect' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in `send' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in `evaluate_method' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:166:in `call' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:93:in `run' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in `each' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in `send' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:92:in `run' /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:276:in `run_callbacks' /home/rails/.gem/ruby/1.8/gems/authlogic-2.1.2/lib/authlogic/session/callbacks.rb:72:in `validate' /home/rails/.gem/ruby/1.8/gems/authlogic-2.1.2/lib/authlogic/session/validation.rb:64:in `valid?' /home/rails/.gem/ruby/1.8/gems/authlogic-2.1.2/lib/authlogic/session/existence.rb:65:in `save'
I'm not sure what other information you need.
My callback url in facebook is mysite.com/users and the callback redirect is mysite.com/account.
Thanks in advance for your support and the plugin.
Is it possible?
When I try to create a new session for a user that doesn't exist in the database it throws an error saying that the persistence_token can't be null. Perhaps I don't fully understand what I'm supposed to do to fix that problem, but if I just change your code to: "self.attempted_record.save_with_validation(true)" or even "self.attempted_record.save" everything works just fine. Did I just compromise something by making this change?
By the way I'm using facebooker 1.0.44 and authlogic 2.1.1 and the latest version of your plugin (as of July 30th).
Thanks for creating this plugin by the way!
Is there any plan to change this plugin to use facebooker2 and the new JS API from facebook?
I am new using this plugin and I had a lot of trouve to get it work straight without having to google for help.
One of the updates:
class CreateFacebookconnects < ActiveRecord::Migration
def self.up
add_column :users, :name, :string
add_column :users, :facebook_uid, :integer, :limit => 8
add_column :users, :facebook_session_key, :string
end
def self.down
remove_column :users, :facebook_uid
remove_column :users, :name
remove_column :users, :facebook_session_key
end
end
how can I automatically log off from fb when i log off from authlogic and vise versa (automatically)
I'm really struggling to get the authlogic_facebook_connect plugin to behave.
Currently, the first attempt with Facebook Connect works fine, creating a new User and session with the correct uid. The problem is that any subsequent attempt to connect with a different Facebook user will always log me in as that first User.
the Session always seems to persist and the plugin loads the User based on that initial uid.
Anyone have some advice on what I'm doing wrong? or tell me how can in invalidate facebook session from my log-out method
Many thanks
Pravin
Hi and thanks for your work!
I'm experimenting some issues using this plugin.
In my application i use JQuery and the jrails plugin.
Your helper.rb at line 13:
output += " $('connect_to_facebook_form').submit();\n"
offers only the prototype selector.
So, we don't have support for JQuery while facebooker offers this feature.
You think that there will be in the future, or it is better a fork?
Hello,
I commented about the persistence token in an other issue yesterday but I've got just a little more material since then.
In my app right now I use 3 tokens : persistence, perishable and single_access. Following Authlogic example app (Ben's one), the three tokens should not be allowed NULL. I'd like to preserve that since I plan to have both facebook and non-facebook users.
perishable_token and single_access_token don't mess up facebook connect, and before_connect seems a good place to set them in case you have to (maybe you could add that to the readme if it is).
So my code looks like :
def before_connect(facebook_session)
self.single_access_token = Authlogic::Random.friendly_token
self.perishable_token = Authlogic::Random.friendly_token
self.first_name = facebook_session.user.first_name
self.last_name = facebook_session.user.last_name
end
Unfortunately, this doesn't work with the persistence_token.
It's really strange because if I add a persistence_token the same way I do for the two other tokens (friendly_token or hex_token), it gets impossible to login.
But, if I set the facebook_uid to an existing "regular" user (that has a persistence_token), he will be able to log in.
Also, if I manually edit the database entry and put whatever token, it will also.
So it looks like the random token generated during before_connect isn't acceptable, but I don't know why.
Do you have any clue regarding this behavior ?
Thanks
Patch - http://gist.github.com/256345
Behaves similarly to some other authlogic open-id-like login add-ons. You can "register" the user with:
<%= hidden_field_tag 'register_with_facebook_connect', '' %>
<%= link_to_function 'Register with Facebook', "FB.Connect.requireSession(function() { $('register_with_facebook_connect').value = 'true'; $('user_form').submit(); }); return false;", :class => 'facebook_auth' %>
How does one request extended permissions? Adding a :perms key to the hash
<%#= authlogic_facebook_login_button :text => 'Login with Facebook', :v => 2, :perms => "email,user_birthday" %>
causes the FBML to render as
<form id='connect_to_facebook_form' method='post' action='/user_session'>
<input type='hidden' name='authenticity_token' value='CODE HERE'/>
</form>
<script type='text/javascript' charset='utf-8'>
function connect_to_facebook() {
$('connect_to_facebook_form').submit();
}
</script>
<fb:login-button js="prototype" onlogin="connect_to_facebook()" perms="email,user_birthday" v="2">Login with Facebook</fb:login-button>
but clicking on the button serves up the vanilla no-extended-permissions popup, so the form submission is clearly not picking up the perms key-value pair off of the login-button.
What to do?
Thanks.
If the facebook_valid_user is set, creating a session always will fail with the message in the session's errors:
You did not provide any details for authentication.
I have confirmed this against the demo app here:
http://github.com/holden/authlogic_openid_selector_example
Only changes I made were to disable validate_password_field in User and add facebook_valid_user true in UserSession.
I'm trying to log on to facebook connect without having an active authlogic session and I'm getting this error: http://gist.github.com/339599
It looks like the only way this works is when you log on and have a session available.
Hello, and sorry for this new issue!
I've noticed that installing the plugin without any other implementation, many of my tests (units, functionals) return a NoMethodError.
In units for example:
NoMethodError: undefined method `set_facebook_session' for #ActionController::TestRequest:0xb4f53a70
I'm using rails 2.3.4, ruby 1.8.7 (Ubuntu 9.0.4) and i've installed the plugin into a fresh checkout of my trunk; before installing the plugin all my tests are ok.
Anyone got the same error?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.