Example #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //
     // STEP 1: check if system is installed at all
     //
     if (!$this->checkInstallation()) {
         $this->showError(["This system has not been set up properly.", "One or more core components are missing."], 'ERRORS');
         return false;
     }
     //
     // STEP 2: check installation and collect some data
     //
     $login = $this->askName($this->option('login'), null, 'User');
     $pswd = $this->askPswd($this->option('pswd'), $login);
     if (!$this->authUser($login, $pswd)) {
         $this->showError("Invalid credentials or insufficient access right", 'ERRORS');
         return false;
     }
     //
     // STEP 2: collect data
     //
     // @todo need more magic stuff
     $success = true;
     if ($success) {
         $this->accounts = Account::all();
         $this->licTypes = LicenseType::all();
         $this->licenses = License::all();
         $this->orgs = Organization::all();
         $this->users = User::all();
     }
     //
     // STEP 3: show summary or error
     //
     if ($success) {
         $this->info("\n--[SUMMARY]------------------------------------------------");
         $this->info('ACCOUNTs:  ' . $this->accounts->count());
         $this->info('LIC TYPEs: ' . $this->licTypes->count());
         $this->info('LICs:      ' . $this->licenses->count());
         $this->info('ORGs:      ' . $this->orgs->count());
         $this->info('USERs:     ' . $this->users->count());
         $this->info("-----------------------------------------------------------");
     } else {
         if (!empty($this->errMsgs)) {
             $this->showError($this->errMsgs, 'ERRORS');
         }
         $this->showError(["This system has not been set up properly.", "Please re-install and try again."], 'ERRORS');
     }
     return $success;
 }
Example #2
0
 /**
  * Determine if user is valid
  *
  * @note We're authenticating user and verifying that account is active,
  *       but we're not logging the user in or maintining a session.
  *
  * @todo verify that ORG status, ACCOUNT status, and LICENSE are active
  *
  * @return bool
  */
 protected function isValidCLIUser()
 {
     $user = User::where('name', $this->cliLogin)->first();
     if (Hash::check($this->cliPswd, $user->password) && in_array($user->status, [STATUS_ACTIVE, STATUS_LOCKED])) {
         $this->cliUser = $user->id;
         return true;
     }
     return false;
 }