Archived
1
0
Fork 0
This repository has been archived on 2026-04-03. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
httpcb/app/controllers/UserController.php

37 lines
966 B
PHP

<?php
namespace App\Controller;
use App\Controller\ControllerBase,
App\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;
}
}