develop #5

Merged
neintonine merged 2 commits from develop into master 2024-11-07 20:42:58 +00:00
3 changed files with 14 additions and 4 deletions
Showing only changes of commit 41a12d9a82 - Show all commits

View file

@ -37,4 +37,9 @@ final class EnvironmentHandler
public function isProduction(): bool {
return $_SERVER['PRODUCTION'] === 'true';
}
public function useSSL(): bool
{
return $_SERVER['USE_SSL'] === 'true';
}
}

View file

@ -7,12 +7,14 @@ use Doctrine\ORM\EntityManager;
use GamesShop\Api\DiscordAPI;
use GamesShop\ContainerHandler;
use GamesShop\Entities\Account\User;
use GamesShop\Environment\EnvironmentHandler;
use Psr\Http\Message\ServerRequestInterface;
final class DiscordLoginProvider implements LoginProvider
{
public function __construct(
private readonly EntityManager $entityManager
private readonly EntityManager $entityManager,
private readonly EnvironmentHandler $env
)
{
}
@ -20,7 +22,12 @@ final class DiscordLoginProvider implements LoginProvider
public function getUser(ServerRequestInterface $request): User
{
$discordApiHandler = ContainerHandler::get(DiscordAPI::class);
$result = $discordApiHandler->getUserFromCode($request->getQueryParams()['code'], (string)$request->getUri()->withQuery(''));
$result = $discordApiHandler->getUserFromCode(
$request->getQueryParams()['code'],
(string)$request->getUri()
->withScheme($this->env->useSSL() ? 'https' : 'http')
->withQuery('')
);
$repo = $this->entityManager->getRepository(User::class);
$users = $repo->findBy(['loginMethod' => LoginMethod::DISCORD, 'foreignLoginId' => $result['id']]);

View file

@ -15,8 +15,6 @@ require_once __DIR__ . '/../src/php/bootstrap.php';
ContainerHandler::get(CrashHandler::class)->register();
throw new Exception();
$router = ContainerHandler::getInstance()->get(Router::class);
$result = $router->route();