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) {
$form->addPassword('current_password', _('Current password'))
->setRequired()
->addRule($check_current_password, _('Password incorrect'));
$form->addPassword('password', _('New password'))
$form->addPassword('new_password', _('New password'))
->addCondition(Form::FILLED)
->addRule(Form::MIN_LENGTH, sprintf(_('Password must be at least %d charachers'),
MIN_PASSWORD_CHARS), MIN_PASSWORD_CHARS);
$form->addPassword('password_repeat', _('Confirm new password'))
->addConditionOn($form['password'], Form::FILLED)
->addRule(Form::EQUAL, _('Passwords must match'), $form['password']);
$form->addPassword('new_password_repeat', _('Confirm new password'))
->addConditionOn($form['new_password'], Form::FILLED)
->addRule(Form::EQUAL, _('Passwords must match'), $form['new_password']);
$form->addSubmit('send', _('Save'))->setAttribute('class', 'btn-primary');
return $form;
......@@ -50,7 +50,7 @@ $app->get('/user/:id/edit', function ($id) use ($app) {
$form = edit_user_form($dbuser);
$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);
$form = edit_user_form($dbuser);
$form->validate();
......@@ -58,18 +58,18 @@ $app->put('/user/:id', function ($id) use ($app) {
if (!$form->hasErrors()) {
$values = $form->getValues();
if ($values->password) {
if ($values->new_password) {
$dbuser->update(array(
'password' => Passwords::hash($values->password)
'password' => Passwords::hash($values->new_password)
));
//$user->logout();
//$user->login($dbuser->username, $values->password);
//$user->login($dbuser->username, $values->new_password);
}
$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) {
......
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