class SafeDb::Login

Attributes

clip[W]

If the clip switch is present it signifies that the password should be read in from the clipboard. Any text selection puts text into the the clipboard - no need specifically to use Ctrl-c (copy).

login_book_id[W]

Either the @book_name or the @login_book_id may be provided. The @login_book_id takes precedence if both are provided.

suppress_output[W]

The view of chapter and verse names within the book is not printed out after a successful login if this suppress_output flag is set to true.

Public Instance Methods

execute() click to toggle source
# File lib/controller/access/login.rb, line 41
def execute

  @book_id = @login_book_id if @login_book_id
  @book_id = Identifier.derive_ergonomic_identifier( @book_name, Indices::SAFE_BOOK_ID_LENGTH ) unless @login_book_id
  @book_reference = @login_book_id if @login_book_id
  @book_reference = @book_name unless @login_book_id

  unless ( is_book_initialized?() )
    print_not_initialized
    return
  end

  if( StateInspect.is_logged_in?( @book_id ) )
    EvolveState.use_book( @book_id )
    View.new().flow() unless @suppress_output
    return
  end

  book_password = Clipboard.read_password() if @clip
  book_password = KeyPass.password_from_shell( false ) if( @password.nil?() && !@clip )
  book_password = @password unless @password.nil?()

  book_keys = DataMap.new( Indices::MASTER_INDICES_FILEPATH )
  book_keys.use( @book_id )
  is_login_successful = EvolveState.login( book_keys, book_password )
  print_login_failure() unless is_login_successful
  return unless is_login_successful

  View.new().flow() unless @suppress_output

end

Private Instance Methods

print_login_failure() click to toggle source
print_not_initialized() click to toggle source