37 lines
962 B
PHP
37 lines
962 B
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Controller\ControllerBase,
|
|
Form\UserSettings as UserSettingsForm;
|
|
|
|
class UserController extends ControllerBase
|
|
{
|
|
public function settingsAction()
|
|
{
|
|
$user = $this->_getAuth()->getUser();
|
|
|
|
$form = new UserSettingsForm($user);
|
|
|
|
if ($this->request->isPost()) {
|
|
$data = $this->request->getPost();
|
|
|
|
if ($form->isValid($data)) {
|
|
|
|
$new_pw = $form->getValue('passwordNew');
|
|
if (strlen($new_pw) > 0) {
|
|
$hash = password_hash($new_pw, PASSWORD_BCRYPT);
|
|
$user->setPassword($hash);
|
|
}
|
|
$user->save();
|
|
$form->initialize();
|
|
|
|
$this->flash->message('success', 'Settings saved!');
|
|
} else {
|
|
$this->flash->message('error', 'Could not save settings');
|
|
}
|
|
}
|
|
|
|
$this->view->form = $form;
|
|
}
|
|
}
|