DG IZ; connecting/disconnecting from fb
This commit is contained in:
parent
159d72c04c
commit
26478403e2
4 changed files with 19 additions and 10 deletions
|
|
@ -39,7 +39,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def fb_user_info
|
||||
@access_token = cookies[:access_token]
|
||||
@access_token = session[:access_token]
|
||||
@logged_in = @access_token.present?
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,17 @@ class ServicesController < ApplicationController
|
|||
@access_token = access_token_hash["access_token"]
|
||||
|
||||
# TODO: This is where you'd want to store the token in your database
|
||||
# but for now, we'll just keep it in the cookie so we don't need a database
|
||||
cookies[:access_token] = @access_token
|
||||
# but for now, we'll just keep it in the session so we don't need a database
|
||||
session[:access_token] = @access_token
|
||||
flash[:success] = "Authentication successful."
|
||||
end
|
||||
redirect_to edit_user_url current_user
|
||||
end
|
||||
|
||||
def destroy
|
||||
session[:access_token] = nil
|
||||
session[:user_id] = nil
|
||||
redirect_to edit_user_url current_url
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -60,13 +60,14 @@
|
|||
%h2 Services
|
||||
|
||||
%h3 Facebook
|
||||
|
||||
- if @logged_in
|
||||
Logged in to facebook as
|
||||
- @response_hash = MiniFB.get(@access_token, @id, :type => "user")
|
||||
= @response_hash[:user][:name]
|
||||
%p
|
||||
= link_to "Login to Facebook", @fb_access_url
|
||||
%p
|
||||
- if @logged_in
|
||||
Connected to facebook as
|
||||
- @response_hash = MiniFB.get(@access_token, 'me')
|
||||
= @response_hash[:name]
|
||||
= link_to "Disconnect from Facebook", services_destroy_path
|
||||
- else
|
||||
= link_to "Connect to Facebook", @fb_access_url
|
||||
|
||||
|
||||
#submit_block
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ Diaspora::Application.routes.draw do
|
|||
resources :aspects, :except => [:edit]
|
||||
|
||||
match 'services/create', :to => "services#create"
|
||||
match 'services/destroy', :to => "services#destroy"
|
||||
|
||||
match 'warzombie', :to => "dev_utilities#warzombie"
|
||||
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
|
||||
|
|
|
|||
Loading…
Reference in a new issue