mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Fix for #1568
This commit is contained in:
@@ -59,12 +59,19 @@ class Sandstorm
|
|||||||
/** @var UserRepositoryInterface $repository */
|
/** @var UserRepositoryInterface $repository */
|
||||||
$repository = app(UserRepositoryInterface::class);
|
$repository = app(UserRepositoryInterface::class);
|
||||||
$userId = (string)$request->header('X-Sandstorm-User-Id');
|
$userId = (string)$request->header('X-Sandstorm-User-Id');
|
||||||
|
|
||||||
// catch anonymous:
|
// catch anonymous:
|
||||||
$userId = '' === $userId ? 'anonymous' : $userId;
|
$userId = '' === $userId ? 'anonymous' : $userId;
|
||||||
$email = $userId . '@firefly';
|
$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);
|
Auth::guard($guard)->login($user);
|
||||||
$repository->attachRole($user, 'owner');
|
$repository->attachRole($user, 'owner');
|
||||||
app('view')->share('SANDSTORM_ANON', false);
|
app('view')->share('SANDSTORM_ANON', false);
|
||||||
|
@@ -205,7 +205,7 @@ class UserRepository implements UserRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function first(): ?User
|
public function first(): ?User
|
||||||
{
|
{
|
||||||
return User::first();
|
return User::orderBy('id', 'ASC')->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user