Airship\Cabin\Bridge\Blueprint\Skyport::tryUnlockPassword PHP Method

tryUnlockPassword() public method

public tryUnlockPassword ( HiddenString $password ) : boolean
$password HiddenString
return boolean
    public function tryUnlockPassword(HiddenString $password) : bool
    {
        $state = State::instance();
        return Password::verify($password->getString(), $this->installHash, $state->keyring['auth.password_key']);
    }

Usage Example

Example #1
0
 /**
  * Trigger the package uninstall process.
  */
 public function removePackage()
 {
     $expected = ['package', 'supplier', 'type'];
     if (!\Airship\all_keys_exist($expected, $_POST)) {
         \Airship\json_response(['status' => 'ERROR', 'message' => \__('Incomplete request.')]);
     }
     if ($this->skyport->isLocked()) {
         $locked = true;
         if ($this->skyport->isPasswordLocked() && !empty($_POST['password'])) {
             $password = new HiddenString($_POST['password']);
             if ($this->skyport->tryUnlockPassword($password)) {
                 $_SESSION['airship_install_lock_override'] = true;
                 $locked = false;
             }
             unset($password);
         }
         if ($locked) {
             if ($this->skyport->isPasswordLocked()) {
                 \Airship\json_response(['status' => 'PROMPT', 'message' => \__('The skyport is locked. To unlock the skyport, please provide the password.')]);
             }
             \Airship\json_response(['status' => 'ERROR', 'message' => \__('The skyport is locked. You cannot install packages from the web interface.')]);
         }
     }
     try {
         $filter = new SkyportFilter();
         $post = $filter($_POST);
     } catch (\TypeError $ex) {
         $this->log("Input violation", LogLevel::ALERT, \Airship\throwableToArray($ex));
         \Airship\json_response(['status' => 'ERROR', 'message' => 'Type Error']);
         return;
     }
     $output = $this->skyport->forceRemoval($post['type'], $post['supplier'], $post['package']);
     \Airship\json_response(['status' => 'OK', 'message' => $output]);
 }