1
0
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:
Dan Brown
2018-09-22 22:09:34 +01:00
parent 10d08e641c
commit da58c41ab6
2 changed files with 53 additions and 5 deletions

View File

@ -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);
}
/**