mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-03 11:08:28 +00:00
Fix for #1568
This commit is contained in:
@@ -59,12 +59,19 @@ class Sandstorm
|
||||
/** @var UserRepositoryInterface $repository */
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
$userId = (string)$request->header('X-Sandstorm-User-Id');
|
||||
|
||||
// catch anonymous:
|
||||
$userId = '' === $userId ? 'anonymous' : $userId;
|
||||
$email = $userId . '@firefly';
|
||||
$user = $repository->findByEmail($email) ?? $this->createUser($email);
|
||||
Log::debug(sprintf('Sandstorm user email is "%s"', $email));
|
||||
|
||||
// always grab the first user in the Sandstorm DB:
|
||||
$user = $repository->findByEmail($email) ?? $repository->first();
|
||||
// or create somebody if necessary.
|
||||
$user = $user ?? $this->createUser($email);
|
||||
|
||||
// then log this user in:
|
||||
Log::info(sprintf('Sandstorm user ID is "%s"', $userId));
|
||||
Log::info(sprintf('Access to database under "%s"', $email));
|
||||
Auth::guard($guard)->login($user);
|
||||
$repository->attachRole($user, 'owner');
|
||||
app('view')->share('SANDSTORM_ANON', false);
|
||||
|
@@ -205,7 +205,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
*/
|
||||
public function first(): ?User
|
||||
{
|
||||
return User::first();
|
||||
return User::orderBy('id', 'ASC')->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user