mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Prevented attachDefaultRole from trying to re-attach if already existing
Fixes #1003 Added test to cover
This commit is contained in:
@ -95,15 +95,14 @@ class UserRepo
|
||||
|
||||
/**
|
||||
* Give a user the default role. Used when creating a new user.
|
||||
* @param $user
|
||||
* @param User $user
|
||||
*/
|
||||
public function attachDefaultRole($user)
|
||||
public function attachDefaultRole(User $user)
|
||||
{
|
||||
$roleId = setting('registration-role');
|
||||
if ($roleId === false) {
|
||||
$roleId = $this->role->first()->id;
|
||||
if ($roleId !== false && $user->roles()->where('id', '=', $roleId)->count() === 0) {
|
||||
$user->attachRoleId($roleId);
|
||||
}
|
||||
$user->attachRoleId($roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user