Class: SafeDb::Login
Overview
The login use case is given the domain name and if needs be it collects the password then (if correct) logs the user in.
Here are some key facts about the login command
-
its domain name parameter is mandatory
-
it is called at the start of every session
-
it is undone by the logout command
-
it requires the shell token environment variable to be set
-
you can nest login commands thus using multiple domains
-
you can call it with a –with=password switch
-
a space before the command prevents it being logged in .bash_history
-
you can deliver the password in multiple ways
Constant Summary
Constants inherited from UseCase
UseCase::APP_DIR_NAME, UseCase::COMMANDMENT, UseCase::ENV_VAR_KEY_NAME, UseCase::ENV_VAR_PREFIX_A, UseCase::ENV_VAR_PREFIX_B, UseCase::FILE_CONTENT_KEY, UseCase::FILE_KEY_PREFIX, UseCase::FILE_NAME_KEY
Instance Attribute Summary collapse
-
#domain_name ⇒ Object
writeonly
Sets the attribute domain_name.
-
#password ⇒ Object
writeonly
Sets the attribute password.
Attributes inherited from UseCase
Instance Method Summary collapse
- #execute ⇒ Object
-
#pre_validation ⇒ Object
Perform pre-conditional validations in preparation to executing the main flow of events for this use case.
Methods inherited from UseCase
#check_post_conditions, #check_pre_conditions, #cleanup, #config_directory, #config_file, #flow_of_events, #get_master_database, #initialize, #post_validation
Constructor Details
This class inherits a constructor from SafeDb::UseCase
Instance Attribute Details
#domain_name=(value) ⇒ Object (writeonly)
Sets the attribute domain_name
20 21 22 |
# File 'lib/usecase/login.rb', line 20 def domain_name=(value) @domain_name = value end |
#password=(value) ⇒ Object (writeonly)
Sets the attribute password
20 21 22 |
# File 'lib/usecase/login.rb', line 20 def password=(value) @password = value end |
Instance Method Details
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/usecase/login.rb', line 23 def execute return unless ops_key_exists? unless ( KeyApi.is_domain_keys_setup?( @domain_name ) ) print_not_initialized return end ############## Call [[ KeyApi.is_logged_in? ]] - then print msg and skip password collection below ############## Call [[ KeyApi.is_logged_in? ]] - then print msg and skip password collection below ############## Call [[ KeyApi.is_logged_in? ]] - then print msg and skip password collection below ############## Call [[ KeyApi.is_logged_in? ]] - then print msg and skip password collection below ############## Call [[ KeyApi.is_logged_in? ]] - then print msg and skip password collection below ############## Call [[ KeyApi.is_logged_in? ]] - then print msg and skip password collection below domain_secret = KeyPass.password_from_shell( false ) if @password.nil? domain_secret = @password unless @password.nil? ############## Use [[ KeyApi.valid_password? ]] and give error if not valid ############## Use [[ KeyApi.valid_password? ]] and give error if not valid ############## Use [[ KeyApi.valid_password? ]] and give error if not valid ############## Use [[ KeyApi.valid_password? ]] and give error if not valid ############## Use [[ KeyApi.valid_password? ]] and give error if not valid KeyApi.do_login( @domain_name, domain_secret, create_header() ) view_uc = View.new view_uc.flow_of_events end |
#pre_validation ⇒ Object
Perform pre-conditional validations in preparation to executing the main flow of events for this use case. This method may throw the below exceptions.
62 63 64 |
# File 'lib/usecase/login.rb', line 62 def pre_validation end |