Class: ApipieBindings::Authenticators::CredentialsLegacy

Inherits:
Base
  • Object
show all
Defined in:
lib/apipie_bindings/authenticators/credentials_legacy.rb

Instance Method Summary collapse

Methods inherited from Base

#name, #response

Constructor Details

#initialize(credentials) ⇒ CredentialsLegacy


6
7
8
# File 'lib/apipie_bindings/authenticators/credentials_legacy.rb', line 6

def initialize(credentials)
  @credentials = credentials
end

Instance Method Details

#authenticate(request, args) ⇒ Object


10
11
12
13
# File 'lib/apipie_bindings/authenticators/credentials_legacy.rb', line 10

def authenticate(request, args)
  params = @credentials.to_params
  request.basic_auth(params[:user], params[:password])
end

#clearObject


19
20
21
# File 'lib/apipie_bindings/authenticators/credentials_legacy.rb', line 19

def clear
  @credentials.clear
end

#error(ex) ⇒ Object


15
16
17
# File 'lib/apipie_bindings/authenticators/credentials_legacy.rb', line 15

def error(ex)
  @credentials.clear if ex.is_a? RestClient::Unauthorized
end