Sha256: 47c6e5b98efd9b9b2339515ff7b1d30b2bc2cc7100c975df87af8029eb07dfd6

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 Bytes

Contents

module Sso
  module Warden
    module Hooks
      class BeforeLogout
        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: user, warden: warden, options: options).call
          end
        end

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

        def call
          # Only run if user is logged in
          if logged_in?
            debug { "Logout Sso::Session - #{session["sso_session_id"]}" }
            Sso::Session.logout(session["sso_session_id"])
          end
        end

        def scope
          scope = options[:scope]
        end

        def session
          warden.session(scope)
        end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doorkeeper_sso-0.2.0 lib/sso/warden/hooks/before_logout.rb