Sha256: 8218c625222e203f5b1c96f07cc34263588e94fa3b8e1ac9c55f5501927b14ae

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

module Sso
  class Pingback
    include ::Sso::Logging

    attr_reader :user, :warden, :options
    delegate :request, to: :warden
    delegate :params, to: :request

    def self.to_proc
      proc do |user, warden, options|
        new(user, warden, options).call
      end
    end

    def initialize(user, warden, options)
      @user, @warden, @options = user, warden, options
    end

    def call
      execute if logged_in?
    end

    def execute
      return false unless sso_session = ::Sso::Session.find_by_id(session["sso_session_id"])
      ::Doorkeeper::Application.all.each do |app|
        debug { "Pingback Sso::Pingback for #{app.inspect}" }
        unless app.pingback_uri.blank?
          data = ::Sso::SessionSerializer.new(sso_session)
          debug { data.inspect }
          notifier = ::Sso::Notifier.new(app.pingback_uri, app.uid, app.secret, data)
          notifier.execute
        end
      end
    end

    def scope
      scope = options[:scope]
    end

    def session
      warden.session(scope)
    end

    def logged_in?
      warden.authenticated?(scope) && session && user
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
doorkeeper_sso-0.4.1 app/models/sso/pingback.rb
doorkeeper_sso-0.4.0 app/models/sso/pingback.rb
doorkeeper_sso-0.2.7 app/models/sso/pingback.rb
doorkeeper_sso-0.2.6 app/models/sso/pingback.rb
doorkeeper_sso-0.2.5 app/models/sso/pingback.rb
doorkeeper_sso-0.2.3 app/models/sso/pingback.rb
doorkeeper_sso-0.2.2 app/models/sso/pingback.rb