fbdoorman 0.8.0.4 → 0.8.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/app/controllers/clearance/facebook_controller.rb +16 -22
- data/lib/clearance/authentication.rb +9 -3
- data/lib/facebook_helpers.rb +1 -3
- data/lib/fbdoorman.rb +4 -2
- 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.5"
|
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}/**/*"]
|
@@ -3,29 +3,23 @@ class Clearance::FacebookController < ApplicationController
|
|
3
3
|
#Js is informing that the cookie was created
|
4
4
|
def index
|
5
5
|
if signed_in? then
|
6
|
-
redirect_to
|
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
|
+
#Validate the token in the cookie
|
9
10
|
@fbcookie = parse_fb_cookie
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
if authenticated_fbu? then
|
12
|
+
@user = find_fbuser(fbu.id) #The one from the DB
|
13
|
+
#If the user exists
|
14
|
+
if @user then
|
15
|
+
sign_in_fbu(@user, params[:token], params[:expiration])
|
16
|
+
else #If theres no user with that id
|
17
|
+
#Register this user
|
18
|
+
register_fbu(fbu)
|
19
|
+
end
|
20
|
+
else #The token isn't valid
|
21
|
+
closed
|
20
22
|
end
|
21
|
-
@user = find_fbuser(fbu.id) #The one from the DB
|
22
|
-
#If the user exists
|
23
|
-
if @user then
|
24
|
-
sign_in_fbu(@user)
|
25
|
-
else #If theres no user with that id
|
26
|
-
#Register this user
|
27
|
-
register_fbu(fbu)
|
28
|
-
end
|
29
23
|
end
|
30
24
|
end
|
31
25
|
|
@@ -37,7 +31,7 @@ class Clearance::FacebookController < ApplicationController
|
|
37
31
|
|
38
32
|
def sign_in_fbu(myuser)
|
39
33
|
sign_in(myuser)
|
40
|
-
redirect_to
|
34
|
+
redirect_to LOGGED_PATH and return
|
41
35
|
end
|
42
36
|
|
43
37
|
#Here I reply the create the new user, I changed te verifications so that fbid is unique and password is optional
|
@@ -48,9 +42,9 @@ class Clearance::FacebookController < ApplicationController
|
|
48
42
|
@user.name = new_user.name
|
49
43
|
@user.email2 = new_user.email
|
50
44
|
if @user.save
|
51
|
-
sign_in_fbu(@user)
|
45
|
+
sign_in_fbu(@user, params[:token], params[:expiration])
|
52
46
|
else
|
53
|
-
render :text => "
|
47
|
+
render :text => "Please contact the administrator, the Facebook user couldn't be created."
|
54
48
|
end
|
55
49
|
end
|
56
50
|
|
@@ -64,12 +64,18 @@ module Clearance
|
|
64
64
|
#
|
65
65
|
# @example
|
66
66
|
# sign_in(@user)
|
67
|
-
def sign_in(user)
|
67
|
+
def sign_in(user, fb_token = nil, token_expiration = nil)
|
68
68
|
if user
|
69
69
|
cookies[:remember_token] = {
|
70
70
|
:value => user.remember_token,
|
71
71
|
:expires => 1.year.from_now.utc
|
72
72
|
}
|
73
|
+
if user_from_fb? then
|
74
|
+
cookies[:fb_token] = {
|
75
|
+
:value => fb_token,
|
76
|
+
:expires => token_expiration
|
77
|
+
}
|
78
|
+
end
|
73
79
|
self.current_user = user
|
74
80
|
end
|
75
81
|
end
|
@@ -81,8 +87,7 @@ module Clearance
|
|
81
87
|
def sign_out
|
82
88
|
current_user.reset_remember_token! if current_user
|
83
89
|
cookies.delete(:remember_token)
|
84
|
-
|
85
|
-
delete_fb_cookie
|
90
|
+
cookies.delete(:fb_token)
|
86
91
|
self.current_user = nil
|
87
92
|
end
|
88
93
|
|
@@ -99,6 +104,7 @@ module Clearance
|
|
99
104
|
def fb_deny_access(flash_message = nil)
|
100
105
|
store_location
|
101
106
|
flash[:failure] = flash_message if flash_message
|
107
|
+
|
102
108
|
redirect_to FB_CLOSED_URL
|
103
109
|
end
|
104
110
|
|
data/lib/facebook_helpers.rb
CHANGED
data/lib/fbdoorman.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'mini_fb'
|
2
2
|
require 'facebook_helpers'
|
3
|
+
require 'request_parser'
|
4
|
+
|
3
5
|
require 'clearance/extensions/errors'
|
4
6
|
require 'clearance/extensions/rescue'
|
5
7
|
require 'clearance/configuration'
|
@@ -21,8 +23,8 @@ FB_CALLBACK_URL = "#{FB[:base_url]}/facebook"
|
|
21
23
|
#This routed will be name with clearance routes as /facebookclosed
|
22
24
|
FB_CLOSED_URL = "#{FB[:base_url]}/fbclosed"
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
LOGGED_PATH = FB[:after_login_path]
|
27
|
+
REGISTERED_PATH = FB[:after_register_path]
|
26
28
|
|
27
29
|
URL_AFTER_CREATE = FB[:url_after_create]
|
28
30
|
|