Sha256: cb626587a65bb539feee1cda48bf6a6f09fde06a1a494f0b54deea67f8ec8d09

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

module CampactUserService
  class Session
    attr_reader :client, :session_cookie_name, :session_id

    def initialize(client, session_id, session_cookie_name)
      @client = client
      @session_id = session_id
      @session_cookie_name = session_cookie_name
    end

    def external_user_id
      session["external_user_id"]
    end

    def has_soft_login_session?
      session["permission_level"] == 'limited'
    end

    def has_hard_login_session?
      session["permission_level"] == 'full'
    end

    def destroy
      client.delete_request('/v1/sessions', cookies: {session_cookie_name => session_id})
    end

    private

    def session
      @session_info ||= (client.get_request('/v1/sessions', cookies: {session_cookie_name => session_id}) || {})
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
campact_user_service-4.1.0 lib/campact_user_service/session.rb