diff --git a/formwork/src/Users/User.php b/formwork/src/Users/User.php index 3488503b5..137a184e7 100644 --- a/formwork/src/Users/User.php +++ b/formwork/src/Users/User.php @@ -191,7 +191,7 @@ public function isAdmin(): bool */ public function canDeleteUser(User $user): bool { - return $this->isAdmin() && !$user->isLoggedIn(); + return $this->isAdmin() && $this->username() !== $user->username(); } /** @@ -199,10 +199,7 @@ public function canDeleteUser(User $user): bool */ public function canChangeOptionsOf(User $user): bool { - if ($this->isAdmin()) { - return true; - } - return $user->isLoggedIn(); + return $this->isAdmin() || $this->username() === $user->username(); } /** @@ -210,7 +207,7 @@ public function canChangeOptionsOf(User $user): bool */ public function canChangePasswordOf(User $user): bool { - return $user->isLoggedIn(); + return $this->username() === $user->username(); } /** @@ -218,7 +215,7 @@ public function canChangePasswordOf(User $user): bool */ public function canChangeRoleOf(User $user): bool { - return $this->isAdmin() && !$user->isLoggedIn(); + return $this->isAdmin() && $this->username() !== $user->username(); } /**