mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Allow users to hand out admin rights.
This commit is contained in:
@@ -293,11 +293,16 @@ class UserRepository implements UserRepositoryInterface
|
||||
/**
|
||||
* Remove any role the user has.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
* @param string $role
|
||||
*/
|
||||
public function removeRole(User $user): void
|
||||
public function removeRole(User $user, string $role): void
|
||||
{
|
||||
$user->roles()->sync([]);
|
||||
$roleObj = $this->getRole($role);
|
||||
if (null === $roleObj) {
|
||||
return;
|
||||
}
|
||||
$user->roles()->detach($roleObj->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,7 +369,8 @@ class UserRepository implements UserRepositoryInterface
|
||||
$user->blocked_code = $data['blocked_code'];
|
||||
}
|
||||
if (isset($data['role']) && '' === $data['role']) {
|
||||
$this->removeRole($user);
|
||||
$this->removeRole($user, 'owner');
|
||||
$this->removeRole($user, 'demo');
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
@@ -157,9 +157,10 @@ interface UserRepositoryInterface
|
||||
/**
|
||||
* Remove any role the user has.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $user
|
||||
* @param string $role
|
||||
*/
|
||||
public function removeRole(User $user): void;
|
||||
public function removeRole(User $user, string $role): void;
|
||||
|
||||
/**
|
||||
* Set MFA code.
|
||||
|
Reference in New Issue
Block a user