fbdoorman 0.8.0.6 → 0.8.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/app/controllers/clearance/facebook_controller.rb +1 -3
- data/lib/clearance/authentication.rb +1 -1
- data/lib/facebook_helpers.rb +10 -6
- metadata +1 -1
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.summary = "Rails authentication with facebook single sign-on OR email & password."
|
19
19
|
gem.description = "Painless user registration and sign-in using Facebook single sign-on with JS. Typical email login still works too."
|
20
20
|
gem.email = "pelaez89@gmail.com"
|
21
|
-
gem.version = "0.8.0.
|
21
|
+
gem.version = "0.8.0.7"
|
22
22
|
gem.homepage = "http://github.com/davidpelaez/minifb-clearance"
|
23
23
|
gem.authors = ["Fbdoorman: David Pelaez","MiniFB: Appoxy","Clearance: Thoughtbot"]
|
24
24
|
gem.files = FileList["[A-Z]*", "{app,config,generators,lib,shoulda_macros,rails}/**/*"]
|
@@ -6,9 +6,7 @@ class Clearance::FacebookController < ApplicationController
|
|
6
6
|
redirect_to LOGGED_PATH #Evita multiples logins y hace que solo tenga sentido llamar el metodo con un nuevo cookie
|
7
7
|
else #If there's no signed in user
|
8
8
|
#The code arrives here
|
9
|
-
|
10
|
-
@fbcookie = parse_fb_cookie
|
11
|
-
if authenticated_fbu?(params[:token]) then
|
9
|
+
if token_user(params[:token]) != nil then
|
12
10
|
@user = find_fbuser(fbu.id) #The one from the DB
|
13
11
|
#If the user exists
|
14
12
|
if @user then
|
data/lib/facebook_helpers.rb
CHANGED
@@ -12,16 +12,20 @@ def user_from_fb?
|
|
12
12
|
end
|
13
13
|
|
14
14
|
#Si da false entonces el usuario se le deniega el acceso
|
15
|
-
def authenticated_fbu?
|
16
|
-
|
17
|
-
if
|
15
|
+
def authenticated_fbu?
|
16
|
+
token = cookies[:fb_token]
|
17
|
+
if token.nil? then return false end
|
18
|
+
if token_user(token) == current_user.fbid then return true else return false end
|
19
|
+
#The user is authenticated if the UID than own the token is the same as the one in current user
|
20
|
+
end
|
21
|
+
|
22
|
+
def token_user(token)
|
18
23
|
begin
|
19
24
|
@uid = MiniFB.rest(token, "users.getLoggedInUser", {})
|
20
|
-
|
25
|
+
return @uid.to_hash["response"]
|
21
26
|
rescue MiniFB::FaceBookError #Is this error happen the token expired
|
22
|
-
return
|
27
|
+
return nil
|
23
28
|
end
|
24
|
-
#The user is authenticated if the UID than own the token is the same as the one in current user
|
25
29
|
end
|
26
30
|
|
27
31
|
|