From d26a5a6e9cffa65534a65de28ca4f7b199d56e45 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 16 Jul 2022 17:15:44 +0200 Subject: [PATCH] Fix https://github.com/firefly-iii/firefly-iii/issues/6150 --- app/Support/Authentication/RemoteUserProvider.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Support/Authentication/RemoteUserProvider.php b/app/Support/Authentication/RemoteUserProvider.php index 7d152665d2..2d309e018b 100644 --- a/app/Support/Authentication/RemoteUserProvider.php +++ b/app/Support/Authentication/RemoteUserProvider.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace FireflyIII\Support\Authentication; use FireflyIII\Exceptions\FireflyException; +use FireflyIII\Models\Role; use FireflyIII\User; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\UserProvider; @@ -63,6 +64,13 @@ class RemoteUserProvider implements UserProvider 'password' => bcrypt(Str::random(64)), ] ); + // if this is the first user, give them admin as well. + if(1 === User::count()) { + $roleObject = Role::where('name', 'owner')->first(); + $user->roles()->attach($roleObject); + } + + } Log::debug(sprintf('Going to return user #%d (%s)', $user->id, $user->email));