Commit 6544335c authored by Taddeus Kroes's avatar Taddeus Kroes

Changed field names on password change page to improve form auto-completion

parent 3bca7331
...@@ -29,13 +29,13 @@ function edit_user_form($dbuser) { ...@@ -29,13 +29,13 @@ function edit_user_form($dbuser) {
$form->addPassword('current_password', _('Current password')) $form->addPassword('current_password', _('Current password'))
->setRequired() ->setRequired()
->addRule($check_current_password, _('Password incorrect')); ->addRule($check_current_password, _('Password incorrect'));
$form->addPassword('password', _('New password')) $form->addPassword('new_password', _('New password'))
->addCondition(Form::FILLED) ->addCondition(Form::FILLED)
->addRule(Form::MIN_LENGTH, sprintf(_('Password must be at least %d charachers'), ->addRule(Form::MIN_LENGTH, sprintf(_('Password must be at least %d charachers'),
MIN_PASSWORD_CHARS), MIN_PASSWORD_CHARS); MIN_PASSWORD_CHARS), MIN_PASSWORD_CHARS);
$form->addPassword('password_repeat', _('Confirm new password')) $form->addPassword('new_password_repeat', _('Confirm new password'))
->addConditionOn($form['password'], Form::FILLED) ->addConditionOn($form['new_password'], Form::FILLED)
->addRule(Form::EQUAL, _('Passwords must match'), $form['password']); ->addRule(Form::EQUAL, _('Passwords must match'), $form['new_password']);
$form->addSubmit('send', _('Save'))->setAttribute('class', 'btn-primary'); $form->addSubmit('send', _('Save'))->setAttribute('class', 'btn-primary');
return $form; return $form;
...@@ -50,7 +50,7 @@ $app->get('/user/:id/edit', function ($id) use ($app) { ...@@ -50,7 +50,7 @@ $app->get('/user/:id/edit', function ($id) use ($app) {
$form = edit_user_form($dbuser); $form = edit_user_form($dbuser);
$app->render('user/edit', compact('dbuser', 'form')); $app->render('user/edit', compact('dbuser', 'form'));
}); });
$app->put('/user/:id', function ($id) use ($app) { $app->put('/user/:id', function ($id) use ($app, $user) {
$dbuser = find_user($id); $dbuser = find_user($id);
$form = edit_user_form($dbuser); $form = edit_user_form($dbuser);
$form->validate(); $form->validate();
...@@ -58,18 +58,18 @@ $app->put('/user/:id', function ($id) use ($app) { ...@@ -58,18 +58,18 @@ $app->put('/user/:id', function ($id) use ($app) {
if (!$form->hasErrors()) { if (!$form->hasErrors()) {
$values = $form->getValues(); $values = $form->getValues();
if ($values->password) { if ($values->new_password) {
$dbuser->update(array( $dbuser->update(array(
'password' => Passwords::hash($values->password) 'password' => Passwords::hash($values->new_password)
)); ));
//$user->logout(); //$user->logout();
//$user->login($dbuser->username, $values->password); //$user->login($dbuser->username, $values->new_password);
} }
$app->redirect(ROOT_URL . "/user/$id"); $app->redirect(ROOT_URL . "/user/$id");
} }
$app->render('user/edit', compact('form')); $app->render('user/edit', compact('dbuser', 'form'));
}); });
$app->put('/user/:id', function ($id) { $app->put('/user/:id', function ($id) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment