Fix missing error notification when editing users is forbidden

This commit is contained in:
Giuseppe Criscione 2018-10-10 00:27:48 +02:00
parent 180b16f86d
commit 22de37dfb1
3 changed files with 7 additions and 6 deletions

View File

@ -197,6 +197,7 @@ users.user.cannot-change-role: Cannot change the role of %s. The action is not a
users.user.cannot-create.already-exists: Cannot create user, a user with the same name already exists
users.user.cannot-create.var-missing: Cannot create user, missing %s variable
users.user.cannot-delete: Cannot delete user. You must be an administrator and the user must not be logged in.
users.user.cannot-edit: Cannot edit user %s. The action is not allowed.
users.user.created: User created
users.user.deleted: User deleted
users.user.edited: User data updated

View File

@ -198,6 +198,7 @@ users.user.cannot-change-role: Impossible cambare il ruolo di %s. Lazione non
users.user.cannot-create.already-exists: Impossibile creare lutente, un utente con lo stesso nome esiste già
users.user.cannot-create.var-missing: Impossibile creare lutente, manca la variabile %s
users.user.cannot-delete: Impossibile eliminare lutente. Devi essere un amministratore e lutente non deve essere connesso.
users.user.cannot-edit: Impossibile modificare lutente %s. Lazione non è consentita.
users.user.created: Utente creato
users.user.deleted: Utente eliminato
users.user.edited: Dati utente aggiornati

View File

@ -112,13 +112,12 @@ class Users extends AbstractController
}
if (HTTPRequest::method() === 'POST') {
if (!$this->user()->canChangeOptionsOf($user)) {
$this->redirect('/users/' . $user->username() . '/profile/', 302, true);
if ($this->user()->canChangeOptionsOf($user)) {
$this->updateUser($user);
$this->notify($this->label('users.user.edited'), 'success');
} else {
$this->notify($this->label('users.user.cannot-edit', $user->username()), 'error');
}
$this->updateUser($user);
$this->notify($this->label('users.user.edited'), 'success');
$this->redirect('/users/' . $user->username() . '/profile/', 302, true);
}