Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions formwork/src/Users/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,34 +191,31 @@ public function isAdmin(): bool
*/
public function canDeleteUser(User $user): bool
{
return $this->isAdmin() && !$user->isLoggedIn();
return $this->isAdmin() && $this->username() !== $user->username();
}
Comment thread
giuscris marked this conversation as resolved.

/**
* Return whether the user can change options of a given user
*/
public function canChangeOptionsOf(User $user): bool
{
if ($this->isAdmin()) {
return true;
}
return $user->isLoggedIn();
return $this->isAdmin() || $this->username() === $user->username();
}

/**
* Return whether the user can change the password of a given user
*/
public function canChangePasswordOf(User $user): bool
{
return $user->isLoggedIn();
return $this->username() === $user->username();
}

/**
* Return whether the user can change the role of a given user
*/
public function canChangeRoleOf(User $user): bool
{
return $this->isAdmin() && !$user->isLoggedIn();
return $this->isAdmin() && $this->username() !== $user->username();
}

/**
Expand Down
Loading