Module: Nurego::Auth
- Included in:
- PasswordReset
- Defined in:
- lib/nurego/auth.rb
Class Attribute Summary collapse
-
.client_id ⇒ Object
Returns the value of attribute client_id.
-
.client_secret ⇒ Object
Returns the value of attribute client_secret.
-
.header_token ⇒ Object
Returns the value of attribute header_token.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.provider_site ⇒ Object
Returns the value of attribute provider_site.
Class Method Summary collapse
- .change_password(user_id, password, current_password) ⇒ Object
- .login(username, password) ⇒ Object
- .logout ⇒ Object
Class Attribute Details
.client_id ⇒ Object
Returns the value of attribute client_id.
15 16 17 |
# File 'lib/nurego/auth.rb', line 15 def client_id @client_id end |
.client_secret ⇒ Object
Returns the value of attribute client_secret.
15 16 17 |
# File 'lib/nurego/auth.rb', line 15 def client_secret @client_secret end |
.header_token ⇒ Object
Returns the value of attribute header_token.
15 16 17 |
# File 'lib/nurego/auth.rb', line 15 def header_token @header_token end |
.logger ⇒ Object
Returns the value of attribute logger.
15 16 17 |
# File 'lib/nurego/auth.rb', line 15 def logger @logger end |
.provider_site ⇒ Object
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) uaa_user_account.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. == "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 login(username, password) @header_token = fetch_header_token(username, password) end |
.logout ⇒ Object
21 22 23 |
# File 'lib/nurego/auth.rb', line 21 def logout @header_token = nil end |