Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorSettingsPanelPassword.php
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | if ($request->isFormPost()) { | ||||
} else { | } else { | ||||
$next = $this->getPanelURI('?saved=true'); | $next = $this->getPanelURI('?saved=true'); | ||||
} | } | ||||
return id(new AphrontRedirectResponse())->setURI($next); | return id(new AphrontRedirectResponse())->setURI($next); | ||||
} | } | ||||
} | } | ||||
$hash_envelope = new PhutilOpaqueEnvelope($user->getPasswordHash()); | |||||
if (PhabricatorPasswordHasher::canUpgradeHash($hash_envelope)) { | |||||
$best_hash = PhabricatorPasswordHasher::getBestHasher(); | |||||
$errors[] = pht( | |||||
'The strength of your stored password hash can be upgraded. '. | |||||
'To upgrade, either: log out and log in using your password; or '. | |||||
'change your password.'); | |||||
} | |||||
$len_caption = null; | $len_caption = null; | ||||
if ($min_len) { | if ($min_len) { | ||||
$len_caption = pht('Minimum password length: %d characters.', $min_len); | $len_caption = pht('Minimum password length: %d characters.', $min_len); | ||||
} | } | ||||
$form = new AphrontFormView(); | $form = new AphrontFormView(); | ||||
$form | $form | ||||
->setUser($user) | ->setUser($user) | ||||
Show All 18 Lines | $form | ||||
id(new AphrontFormPasswordControl()) | id(new AphrontFormPasswordControl()) | ||||
->setLabel(pht('Confirm Password')) | ->setLabel(pht('Confirm Password')) | ||||
->setCaption($len_caption) | ->setCaption($len_caption) | ||||
->setError($e_conf) | ->setError($e_conf) | ||||
->setName('conf_pw')); | ->setName('conf_pw')); | ||||
$form | $form | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
->setValue(pht('Save'))); | ->setValue(pht('Change Password'))); | ||||
if (!strlen($user->getPasswordHash())) { | |||||
$current_name = pht('None'); | |||||
} else { | |||||
try { | |||||
$current_hasher = PhabricatorPasswordHasher::getHasherForHash( | |||||
new PhutilOpaqueEnvelope($user->getPasswordHash())); | |||||
$current_name = $current_hasher->getHumanReadableName(); | |||||
} catch (Exception $ex) { | |||||
$current_name = pht('Unknown'); | |||||
} | |||||
} | |||||
$form->appendChild( | |||||
id(new AphrontFormStaticControl()) | |||||
->setLabel(pht('Current Algorithm')) | |||||
->setValue($current_name)); | |||||
try { | |||||
$best_hasher = PhabricatorPasswordHasher::getBestHasher(); | |||||
$best_name = $best_hasher->getHumanReadableName(); | |||||
} catch (Exception $ex) { | |||||
$best_name = pht('Unknown'); | |||||
} | |||||
$form->appendChild( | |||||
id(new AphrontFormStaticControl()) | |||||
->setLabel(pht('Best Available Algorithm')) | |||||
->setValue($best_name)); | |||||
$form_box = id(new PHUIObjectBoxView()) | $form_box = id(new PHUIObjectBoxView()) | ||||
->setHeaderText(pht('Change Password')) | ->setHeaderText(pht('Change Password')) | ||||
->setFormSaved($request->getStr('saved')) | ->setFormSaved($request->getStr('saved')) | ||||
->setFormErrors($errors) | ->setFormErrors($errors) | ||||
->setForm($form); | ->setForm($form); | ||||
return array( | return array( | ||||
$form_box, | $form_box, | ||||
); | ); | ||||
} | } | ||||
} | } |