Module: Nurego::Auth

Included in:
PasswordReset
Defined in:
lib/nurego/auth.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.client_idObject

Returns the value of attribute client_id.



15
16
17
# File 'lib/nurego/auth.rb', line 15

def client_id
  @client_id
end

.client_secretObject

Returns the value of attribute client_secret.



15
16
17
# File 'lib/nurego/auth.rb', line 15

def client_secret
  @client_secret
end

.header_tokenObject

Returns the value of attribute header_token.



15
16
17
# File 'lib/nurego/auth.rb', line 15

def header_token
  @header_token
end

.loggerObject

Returns the value of attribute logger.



15
16
17
# File 'lib/nurego/auth.rb', line 15

def logger
  @logger
end

.provider_siteObject

Returns the value of attribute provider_site.



15
16
17
# File 'lib/nurego/auth.rb', line 15

def provider_site
  @provider_site
end

Class Method Details

.change_password(user_id, password, current_password) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/nurego/auth.rb', line 25

def change_password(user_id, password, current_password)
  .change_password(user_id, password, current_password)
rescue CF::UAA::NotFound, CF::UAA::TargetError => e
  raise UserNotFoundError.new('User not found') # TODO better error message
rescue CF::UAA::AuthError, CF::UAA::BadResponse => e
  raise AuthenticationError.new('OAuth authentication failed ' +
                                    'Make sure you set "Nurego.client_id = <client_id>". ' +
                                    'Please also make sure you set "Nurego.client_secret = <client secret>". ' +
                                    'See https://www.nurego.com/api for details, or email [email protected] ' +
                                    'if you have any questions.') if e.message == "status 401" || e.is_a?(CF::UAA::AuthError)
  raise NuregoError "fetch_access_info #{e.inspect}"
end

.login(username, password) ⇒ Object



17
18
19
# File 'lib/nurego/auth.rb', line 17

def (username, password)
  @header_token = fetch_header_token(username, password)
end

.logoutObject



21
22
23
# File 'lib/nurego/auth.rb', line 21

def logout
  @header_token = nil
end