fbdoorman 0.8.0.7 → 0.8.0.8

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 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.7"
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
- if token_user(params[:token]) != nil then
10
- @user = find_fbuser(fbu.id) #The one from the DB
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
- sign_in_fbu(@user, params[:token], params[:expiration])
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(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
- def sign_in_fbu(myuser)
31
- sign_in(myuser)
32
- redirect_to LOGGED_PATH and return
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(new_user)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbdoorman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.7
4
+ version: 0.8.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: