Sha256: dcf10fd87571908193b02aefa62288b9d772ad7b39e464e955949cd2a3568689

Contents?: true

Size: 910 Bytes

Versions: 11

Compression:

Stored size: 910 Bytes

Contents

module Ishapi
  module My
    class MyController < Ishapi::ApplicationController

      # before_action :set_profile # this is DoS on FB - disabled
      # before_action :do_login
      before_action :check_profile

      def account
        @profile = current_user.profile
        authorize! :show, @profile
      end

      private

      def do_login
        token = decode(params[:jwtToken])
        @current_user = User.find(token["user_id"])
      end

      def set_profile
        begin
          @graph   = Koala::Facebook::API.new( params[:accessToken] )
          me       = @graph.get_object( 'me', :fields => 'email' )
          @profile = IshModels::UserProfile.find_by :email => me['email']
        rescue Koala::Facebook::AuthenticationError => e
          render :json => { :status => :not_ok, :errors => "Probably expired token." }
          return
        end
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ishapi-0.1.8.145 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.144 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.143 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.142 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.141 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.140 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.139 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.138 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.137 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.136 app/controllers/ishapi/my/my_controller.rb
ishapi-0.1.8.135 app/controllers/ishapi/my/my_controller.rb