James Cole 2022-07-16 17:15:44 +02:00
parent 29dce924cf
commit d26a5a6e9c
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80

View File

@ -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));