fbdoorman 0.8.0.7 → 0.8.0.8
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 +24 -9
- 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.8"
|
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,14 +6,16 @@ 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
|
-
|
9
|
+
user_id = token_user(params[:token])
|
10
|
+
if user_id != nil then
|
11
|
+
@user = find_fbuser(user_id) #The one from the DB
|
11
12
|
#If the user exists
|
12
13
|
if @user then
|
13
|
-
|
14
|
+
sign_in(@user, params[:token], params[:expiration])
|
15
|
+
redirect_to LOGGED_PATH and return
|
14
16
|
else #If theres no user with that id
|
15
17
|
#Register this user
|
16
|
-
register_fbu(
|
18
|
+
register_fbu(token)
|
17
19
|
end
|
18
20
|
else #The token isn't valid
|
19
21
|
closed
|
@@ -27,14 +29,27 @@ class Clearance::FacebookController < ApplicationController
|
|
27
29
|
render :template => "facebook/closed"
|
28
30
|
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
32
|
+
|
33
|
+
|
34
|
+
|
34
35
|
|
35
36
|
#Here I reply the create the new user, I changed te verifications so that fbid is unique and password is optional
|
36
37
|
# when fbid isn't blank
|
37
|
-
def register_fbu(
|
38
|
+
def register_fbu(token)
|
39
|
+
#get the user from FB
|
40
|
+
##Works sometimes, others sends: JSON::ParserError Exception: source did not contain any JSON!
|
41
|
+
#Bucle posiblemente infinito y chambon para lidiar con la excepcion mientras se soluciona
|
42
|
+
incomplete = true
|
43
|
+
while incomplete do
|
44
|
+
begin
|
45
|
+
incomplete = false #Intento salir del bucle
|
46
|
+
new_user = MiniFB::OAuthSession.new(token, 'es_ES').get "me"
|
47
|
+
rescue JSON::ParserError
|
48
|
+
incomplete = true #Reingreso en el bucle
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
#Build th user in DB
|
38
53
|
@user = ::User.new
|
39
54
|
@user.fbid = new_user.id
|
40
55
|
@user.name = new_user.name
|