facebook_app 0.0.30 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +1,22 @@
1
1
  module FacebookApp
2
2
  class AdminController < FacebookAppController
3
3
  layout "facebook_app"
4
- http_basic_authenticate_with :name => 'identified', :password => 'identified'
5
- before_filter :ensure_logged_in, :only => :log_me_out
6
- before_filter :load_graph, :only => :log_me_out
4
+ http_basic_authenticate_with :name => 'identified', :password => 'identified', :except => :register_app_access_token
5
+ before_filter :load_graph, :only => :uninstall_app
6
+
7
7
 
8
8
  def show
9
9
  @conversion_summary = FacebookApp::ConversionSummary.new
10
-
11
10
  @fb = FacebookApp::FacebookCredentials.current_credentials
12
11
  end
13
12
 
14
13
  def new_fb_credentials
15
- @fb = FacebookApp::FacebookCredentials.new
14
+ @fb = FacebookApp::FacebookCredentials.current_credentials
15
+ end
16
+
17
+ def register_app_access_token
18
+ FacebookApp::FacebookCredentials.register_app_access_token
19
+ render :js => "alert('App access token successfully registered as #{FacebookApp::FacebookCredentials.app_access_token}');".html_safe
16
20
  end
17
21
 
18
22
  def clear_conversion_data
@@ -20,14 +24,12 @@ module FacebookApp
20
24
  redirect_to facebook_app.admin_path
21
25
  end
22
26
 
23
- def log_me_out
24
- @graph.graph_call("#{@graph.get_object('me')['id']}/permissions", {}, :delete)
25
-
27
+ def uninstall_app
26
28
  session[:at] = nil
27
29
  session[:uid] = nil
28
30
  cookies.delete(:conversion_id)
29
31
  flash[:notice] = "You logged out as a Facebook user"
30
- redirect_to facebook_app.admin_path
32
+ redirect_to :back
31
33
  end
32
34
 
33
35
  def create_fb_credentials
@@ -32,13 +32,14 @@ module FacebookSdkHelper
32
32
  javascript_tag("FB.getUserID()")
33
33
  end
34
34
 
35
- # Configurable[:facebook_permissions]
36
35
  def facebook_login(text, permissions, log_in_url)
37
36
  link_to(text, "#", :onclick => "facebookLogin('#{permissions}', '#{log_in_url}'").html_safe
38
37
  end
39
38
 
40
39
  def uninstall_facebook_app_button
41
- button_to_function("Uninstall This Facebook App", "removeAppPermissions()")
40
+ # hackish fix for route since engine in Rails 3.1 tries to double up
41
+ # the initial backslash
42
+ button_to("Uninstall App and Logout", facebook_app.uninstall_app_path.gsub("//","/"), :onclick => "removeAppPermissions()")
42
43
  end
43
44
 
44
45
  def facebook_logout_button
@@ -31,6 +31,15 @@ module FacebookApp
31
31
  current_credentials.secret
32
32
  end
33
33
 
34
+ def app_access_token
35
+ current_credentials.app_access_token || register_app_access_token
36
+ end
37
+
38
+ def register_app_access_token
39
+ oauth = Koala::Facebook::OAuth.new(FacebookApp::FacebookCredentials.app_id, FacebookApp::FacebookCredentials.secret)
40
+ FacebookApp::FacebookCredentials.current_credentials.update_attribute(:app_access_token, oauth.get_app_access_token)
41
+ end
42
+
34
43
  def app_url
35
44
  current_credentials.app_url
36
45
  end
@@ -6,9 +6,8 @@
6
6
  = button_to "Delete Data", facebook_app.clear_conversion_data_path, :confirm => "Are you sure you want to permanently delete all conversion data?"
7
7
  p Remove app permission. Useful for checking if permissions dialogue shows at right time. Will log you in if you are logged out.
8
8
  = uninstall_facebook_app_button
9
- p Register Achievements With Facebook(must be done with each new app)
10
- = button_to "Register Achivements", facebook_app.register_with_fb_achievement_path(1)
11
-
9
+ p Register With Facebook(must be done with each new app)
10
+ = button_to "Register App Access Token & Achivements", facebook_app.register_app_access_token_path, :remote => true
12
11
  ul
13
12
  li
14
13
  h1 Current Facebook Credentials
@@ -1,15 +1,11 @@
1
1
  FacebookApp::Engine.routes.draw do
2
2
 
3
3
  scope(:module => :facebook_app) do
4
- resources :achievements do
5
- member do
6
- post :register_with_fb
7
- end
8
- end
9
4
 
10
5
  get "/channel" => "facebook_sdk#channel", :as => :facebook_channel
11
6
 
12
7
  post "/trackings" => "trackings#create", :as => :trackings
8
+ post "/register_app_access_token" => "admin#register_app_access_token", :as => :register_app_access_token
13
9
 
14
10
  match "/oauth_callback" => "oauth#create", :as => :oauth_callback
15
11
  match "/denied" => "oauth#denied", :as => :denied
@@ -19,7 +15,7 @@ FacebookApp::Engine.routes.draw do
19
15
 
20
16
  get "/admin" => "admin#show"
21
17
  post "/admin/clear_conversion_data" => "admin#clear_conversion_data", :as => :clear_conversion_data
22
- post "/admin/log_me_out" => "admin#log_me_out", :as => :log_me_out
18
+ post "/admin/uninstall_app" => "admin#uninstall_app", :as => :uninstall_app
23
19
 
24
20
  post "/create_fb_credentials" => "admin#create_fb_credentials"
25
21
  get "/new_fb_credentials" => "admin#new_fb_credentials"
@@ -23,6 +23,8 @@ class AddFacebookApp < ActiveRecord::Migration
23
23
  t.boolean "development", :default => false
24
24
  t.string "email"
25
25
  t.string "password"
26
+ # we have logic that creates the token if false
27
+ t.string "app_access_token", :default => false
26
28
  end
27
29
  end
28
30
 
@@ -1,3 +1,3 @@
1
1
  module FacebookApp
2
- VERSION = "0.0.30"
2
+ VERSION = "0.0.32"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: facebook_app
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.30
5
+ version: 0.0.32
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jack Kinsella