Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorPasswordSettingsPanel.php
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | if ($request->isFormPost()) { | ||||
if (!$errors) { | if (!$errors) { | ||||
// This write is unguarded because the CSRF token has already | // This write is unguarded because the CSRF token has already | ||||
// been checked in the call to $request->isFormPost() and | // been checked in the call to $request->isFormPost() and | ||||
// the CSRF token depends on the password hash, so when it | // the CSRF token depends on the password hash, so when it | ||||
// is changed here the CSRF token check will fail. | // is changed here the CSRF token check will fail. | ||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | ||||
$envelope = new PhutilOpaqueEnvelope($pass); | $envelope = new PhutilOpaqueEnvelope($pass); | ||||
id(new PhabricatorUserEditor()) | id(new PhabricatorUserEditor()) | ||||
->setActor($user) | ->setActor($user) | ||||
->changePassword($user, $envelope); | ->changePassword($user, $envelope); | ||||
unset($unguarded); | unset($unguarded); | ||||
if ($token) { | if ($token) { | ||||
// Destroy the token. | // Destroy the token. | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | public function processRequest(AphrontRequest $request) { | ||||
} | } | ||||
$form | $form | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormPasswordControl()) | id(new AphrontFormPasswordControl()) | ||||
->setDisableAutocomplete(true) | ->setDisableAutocomplete(true) | ||||
->setLabel(pht('New Password')) | ->setLabel(pht('New Password')) | ||||
->setError($e_new) | ->setError($e_new) | ||||
->setName('new_pw')); | ->setName('new_pw')) | ||||
$form | |||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormPasswordControl()) | id(new AphrontFormPasswordControl()) | ||||
->setDisableAutocomplete(true) | ->setDisableAutocomplete(true) | ||||
->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 | |||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
->setValue(pht('Change Password'))); | ->setValue(pht('Change Password'))); | ||||
$form->appendChild( | $properties = id(new PHUIPropertyListView()); | ||||
id(new AphrontFormStaticControl()) | |||||
->setLabel(pht('Current Algorithm')) | |||||
->setValue(PhabricatorPasswordHasher::getCurrentAlgorithmName( | |||||
new PhutilOpaqueEnvelope($user->getPasswordHash())))); | |||||
$form->appendChild( | $properties->addProperty( | ||||
id(new AphrontFormStaticControl()) | pht('Current Algorithm'), | ||||
->setLabel(pht('Best Available Algorithm')) | PhabricatorPasswordHasher::getCurrentAlgorithmName( | ||||
->setValue(PhabricatorPasswordHasher::getBestAlgorithmName())); | new PhutilOpaqueEnvelope($user->getPasswordHash()))); | ||||
$form->appendRemarkupInstructions( | $properties->addProperty( | ||||
pht( | pht('Best Available Algorithm'), | ||||
'NOTE: Changing your password will terminate any other outstanding '. | PhabricatorPasswordHasher::getBestAlgorithmName()); | ||||
$info_view = id(new PHUIInfoView()) | |||||
->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | |||||
->appendChild( | |||||
pht('Changing your password will terminate any other outstanding '. | |||||
'login sessions.')); | 'login sessions.')); | ||||
$algo_box = $this->newBox(pht('Password Algorithms'), $properties); | |||||
$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) | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ->setBackground(PHUIObjectBoxView::WHITE_CONFIG) | ||||
->setForm($form); | ->setForm($form); | ||||
return array( | return array( | ||||
$form_box, | $form_box, | ||||
$algo_box, | |||||
$info_view, | |||||
); | ); | ||||
} | } | ||||
} | } |