Skip to content
Extraits de code Groupes Projets
services_controller.rb 1,16 ko
Newer Older
  • Learn to ignore specific revisions
  • danielvincent's avatar
    danielvincent a validé
    #   Copyright (c) 2010, Diaspora Inc.  This file is
    
    Raphael's avatar
    Raphael a validé
    #   licensed under the Affero General Public License version 3 or later.  See
    
    danielvincent's avatar
    danielvincent a validé
    #   the COPYRIGHT file.
    
    
    class ServicesController < ApplicationController
    
      def create
        puts 'services/create'
        p params
    
        code = params['code'] # Facebooks verification string
        if code
    
          access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", FB_SECRET, code)
    
    danielvincent's avatar
    danielvincent a validé
          p access_token_hash
          @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 session so we don't need a database
    
          warden.session[:access_token] = @access_token
    
    danielvincent's avatar
    danielvincent a validé
          flash[:success] = "Authentication successful."
        end
        redirect_to edit_user_url current_user
      end
    
        warden.session[:access_token] = nil
    		warden.session[:user_id] = nil
    
    danielvincent's avatar
    danielvincent a validé
        redirect_to edit_user_url current_user
    
      def fb_post
        id = 'me'
        type = 'feed'
    
        @res = MiniFB.post(@access_token, id, :type=>type, :metadata=>true, :params=>params)
    
        redirect_to edit_user_url current_user
    
    danielvincent's avatar
    danielvincent a validé
    end