Class: Configuration::CredentialsConfiguration
- Inherits:
-
Configuration
- Object
- Configuration
- Configuration::CredentialsConfiguration
- Defined in:
- lib/configuration/credentials_configuration.rb
Overview
Configuration for credentials.
Instance Attribute Summary
Attributes inherited from Configuration
Instance Method Summary collapse
- #decrypted_password ⇒ Object
-
#login_credentials ⇒ AccountCredentials
Read credentials from configuration file.
- #login_credentials_empty? ⇒ Boolean
-
#update_login_credentials(username, password) ⇒ Object
Update login credentials in configuration file.
Methods inherited from Configuration
Constructor Details
This class inherits a constructor from Configuration::Configuration
Instance Method Details
#decrypted_password ⇒ Object
43 44 45 46 |
# File 'lib/configuration/credentials_configuration.rb', line 43 def decrypted_password decrypt(data[:credentials][:password][:cipher], data[:credentials][:password][:iv]) end |
#login_credentials ⇒ AccountCredentials
Read credentials from configuration file
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/configuration/credentials_configuration.rb', line 26 def login_credentials if login_credentials_empty? raise LogworkException::ConfigurationValueNotFound.new, "Cannot read username/password from configuration file at '#{manager.configuration_path}'." end AccountCredentials.new(username: data[:credentials][:username], password: decrypted_password, is_stored: true) end |
#login_credentials_empty? ⇒ Boolean
37 38 39 40 41 |
# File 'lib/configuration/credentials_configuration.rb', line 37 def login_credentials_empty? data[:credentials].nil? || data[:credentials][:username].nil? || data[:credentials][:password].nil? end |
#update_login_credentials(username, password) ⇒ Object
Update login credentials in configuration file
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/configuration/credentials_configuration.rb', line 52 def update_login_credentials(username, password) if !username.nil? && !password.nil? encrypted_password = encrypt(password) data[:credentials] = { username: username, password: encrypted_password } else data.delete(:credentials) end manager.save_configuration end |