Class: Sso::Pingback

Inherits:
Object
  • Object
show all
Includes:
Logging, Warden::Support
Defined in:
app/models/sso/pingback.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Warden::Support

#logged_in?, #scope, #session

Methods included from Logging

#debug, #error, #fatal, #info, #warn

Constructor Details

#initialize(user, warden, options) ⇒ Pingback

Returns a new instance of Pingback.



16
17
18
# File 'app/models/sso/pingback.rb', line 16

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'app/models/sso/pingback.rb', line 6

def options
  @options
end

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'app/models/sso/pingback.rb', line 6

def user
  @user
end

#wardenObject (readonly)

Returns the value of attribute warden.



6
7
8
# File 'app/models/sso/pingback.rb', line 6

def warden
  @warden
end

Class Method Details

.to_procObject



10
11
12
13
14
# File 'app/models/sso/pingback.rb', line 10

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

Instance Method Details

#callObject



20
21
22
# File 'app/models/sso/pingback.rb', line 20

def call
  execute if logged_in?
end

#executeObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/sso/pingback.rb', line 24

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