Commit 15e790d5 authored by Roman Ondráček's avatar Roman Ondráček

Core: fix password change for normal users

Signed-off-by: Roman Ondráček's avatarRoman Ondráček <ondracek.roman@centrum.cz>
parent 3649188a
Pipeline #2103 passed with stages
in 14 minutes and 14 seconds
......@@ -113,7 +113,9 @@ class UserEditFormFactory {
$values->newPassword !== '') {
$this->userManager->changePassword($this->id, $values->oldPassword, $values->newPassword);
}
$this->userManager->edit($this->id, $values->username, $values->role, $values->language);
$role = $values->role ?? null;
$language = $values->language ?? null;
$this->userManager->edit($this->id, $values->username, $role, $language);
if ($this->presenter->user->id === $this->id) {
$this->presenter->user->logout();
}
......
......@@ -84,20 +84,22 @@ class UserManager {
* Edits the user
* @param int $id User ID
* @param string $username New username
* @param string $role New user role
* @param string $language New user's language
* @param string|null $role New user role
* @param string|null $language New user's language
* @throws UsernameAlreadyExistsException
*/
public function edit(int $id, string $username, string $role, string $language): void {
public function edit(int $id, string $username, ?string $role, ?string $language): void {
$row = $this->table->where('username', $username)->fetch();
if ($row !== null && $row['id'] !== $id) {
throw new UsernameAlreadyExistsException();
}
$data = [
'username' => $username,
'role' => $role,
'language' => $language,
];
$data = ['username' => $username];
if ($role !== null) {
$data['role'] = $role;
}
if ($language !== null) {
$data['language'] = $language;
}
$this->table->where('id', $id)->update($data);
}
......
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