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 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.6"
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
- #Validate the token in the cookie
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
@@ -70,7 +70,7 @@ module Clearance
70
70
  :value => user.remember_token,
71
71
  :expires => 1.year.from_now.utc
72
72
  }
73
- if user_from_fb? then
73
+ if !user.fbid.blank? then
74
74
  cookies[:fb_token] = {
75
75
  :value => fb_token,
76
76
  :expires => token_expiration
@@ -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?(token=nil)
16
- if token.nil? then token = cookies[:fb_token] end
17
- if @fbcookie.nil? then return false end
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
- if @uid.to_hash["response"] == current_user.fbid then return true else return false end
25
+ return @uid.to_hash["response"]
21
26
  rescue MiniFB::FaceBookError #Is this error happen the token expired
22
- return false
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
 
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.6
4
+ version: 0.8.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: