Compare commits

...
Author SHA1 Message Date
bence a255180a4d Merge pull request 'fix unambiguous where and orderBy statements in PlaceRepository' (!67) from fix-selects-in-placerepository into develop
mapguesser/pipeline/head This commit looks good
Reviewed-on: #67
2023-09-15 01:40:16 +02:00
bence af09da8782 fix unambiguous where and orderBy statements in PlaceRepository
mapguesser/pipeline/pr-develop This commit looks good
2023-09-15 01:38:26 +02:00
bence ddfea0530d Merge pull request 'fix syntax for password input in login form' (!66) from bugfix/fix-login-password-layout into develop
mapguesser/pipeline/head This commit looks good
Reviewed-on: #66
2023-05-16 18:08:37 +02:00
bence 9d7d19899d fix syntax for password input in login form
mapguesser/pipeline/pr-develop This commit looks good
2023-05-16 18:06:30 +02:00
bence 10f032a9a5 Merge pull request 'bugfix/fix-ambiguous-sql-field-names' (!65) from bugfix/fix-ambiguous-sql-field-names into develop
mapguesser/pipeline/head This commit looks good
Reviewed-on: #65
2023-05-02 18:12:04 +02:00
bence c02e35580f use sql field names with tables where join happens
mapguesser/pipeline/pr-develop This commit looks good
2023-05-02 18:10:22 +02:00
bence afd58bb91b update soko-web to 0.10.1 2023-05-02 18:08:53 +02:00
bence fc6792ccfc Merge pull request 'add autocomplete values for username and password fields' (!64) from feature/add-autocompletes-for-usernames-and-passwords into develop
mapguesser/pipeline/head This commit looks good
Reviewed-on: #64
2023-05-02 14:14:55 +02:00
bence a5ba8e71e4 add autocomplete values for username and password fields
mapguesser/pipeline/pr-develop This commit looks good
2023-05-02 14:10:10 +02:00
bence 184f63585c Merge pull request 'feature/session-handler-changes' (!63) from feature/session-handler-changes into develop
mapguesser/pipeline/head This commit looks good
Reviewed-on: #63
2023-05-02 13:20:07 +02:00
bence d666593fde session should be valid for a session
mapguesser/pipeline/pr-develop This commit looks good
2023-05-02 13:18:37 +02:00
bence 75fad05362 adapt to new soko-web interfaces 2023-05-02 13:18:14 +02:00
bence 45b34cb514 update to soko-web 0.10 2023-05-02 13:18:03 +02:00
bence a6ba53764b Merge pull request 'feature/update-soko-web-to-0.7' (!62) from feature/update-soko-web-to-0.7 into develop
mapguesser/pipeline/head This commit looks good
Reviewed-on: #62
2023-04-30 21:07:08 +02:00
bence e70f8a9965 adapt $withRelations usage to soko-web 0.7
mapguesser/pipeline/pr-develop This commit looks good
2023-04-30 21:01:15 +02:00
bence 4aadcab2d2 update soko-web to 0.7 2023-04-30 20:29:43 +02:00
16 changed files with 66 additions and 70 deletions

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@
}
],
"require": {
"esoko/soko-web": "0.6.1",
"esoko/soko-web": "0.10.1",
"fzaninotto/faker": "^1.9"
},
"require-dev": {
Generated
+4 -4
View File
@@ -4,15 +4,15 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8b291ef6518a20a7cdd71ac2c19763d8",
"content-hash": "27b6af78f89ef8dde87e918118511571",
"packages": [
{
"name": "esoko/soko-web",
"version": "0.6.1",
"version": "v0.10.1",
"source": {
"type": "git",
"url": "https://git.esoko.eu/esoko/soko-web.git",
"reference": "445774e59a4891b2e67d151b0cf7b7b880c40e48"
"reference": "585d469b695365e6f8c0f9b596dbb18b6d3ce584"
},
"require": {
"phpmailer/phpmailer": "^6.8",
@@ -33,7 +33,7 @@
"GNU GPL 3.0"
],
"description": "Lightweight web framework",
"time": "2023-04-19T22:24:31+00:00"
"time": "2023-05-02T16:06:33+00:00"
},
{
"name": "fzaninotto/faker",
+5 -5
View File
@@ -138,7 +138,7 @@ class GameFlowController implements IAuthenticationRequired
// if the last round was played ($currentPlace == null) or history is explicitly requested (for initializing)
if (!isset($currentPlace) || $withHistory) {
$withRelations = [User::class, PlaceInChallenge::class, Place::class];
$withRelations = ['user', 'place_in_challange', 'place'];
foreach ($this->guessRepository->getAllInChallenge($challenge, $withRelations) as $guess) {
$round = $guess->getPlaceInChallenge()->getRound();
@@ -187,7 +187,7 @@ class GameFlowController implements IAuthenticationRequired
$prevRound = $currentRound - 1;
if ($prevRound >= 0) {
foreach ($this->guessRepository->getAllInChallengeByRound($prevRound, $challenge, [User::class]) as $guess) {
foreach ($this->guessRepository->getAllInChallengeByRound($prevRound, $challenge, ['user']) as $guess) {
if ($guess->getUser()->getId() != $userId) {
$response['allResults'][] = [
'userName' => $guess->getUser()->getDisplayName(),
@@ -216,7 +216,7 @@ class GameFlowController implements IAuthenticationRequired
$session = \Container::$request->session();
$userId = $session->get('userId');
$challengeToken_str = \Container::$request->query('challengeToken');
$userInChallenge = $this->userInChallengeRepository->getByUserIdAndToken($userId, $challengeToken_str, [Challenge::class]);
$userInChallenge = $this->userInChallengeRepository->getByUserIdAndToken($userId, $challengeToken_str, ['challenge']);
if (!isset($userInChallenge)) {
return new JsonContent(['error' => 'game_not_found']);
@@ -337,7 +337,7 @@ class GameFlowController implements IAuthenticationRequired
$session = \Container::$request->session();
$userId = $session->get('userId');
$challengeToken_str = \Container::$request->query('challengeToken');
$userInChallenge = $this->userInChallengeRepository->getByUserIdAndToken($userId, $challengeToken_str, [Challenge::class]);
$userInChallenge = $this->userInChallengeRepository->getByUserIdAndToken($userId, $challengeToken_str, ['challenge']);
if (!isset($userInChallenge)) {
return new JsonContent(['error' => 'game_not_found']);
@@ -345,7 +345,7 @@ class GameFlowController implements IAuthenticationRequired
$challenge = $userInChallenge->getChallenge();
$currentRound = $userInChallenge->getCurrentRound();
$currentPlaceInChallenge = $this->placeInChallengeRepository->getByRoundInChallenge($currentRound, $challenge, [Place::class, Map::class]);
$currentPlaceInChallenge = $this->placeInChallengeRepository->getByRoundInChallenge($currentRound, $challenge, ['place', 'map']);
$currentPlace = $currentPlaceInChallenge->getPlace();
$map = $currentPlace->getMap();
+1 -1
View File
@@ -218,7 +218,7 @@ class MapAdminController implements IAuthenticationRequired, ISecured
\Container::$persistentDataManager->deleteFromDb($userInChallenge);
}
foreach ($this->guessRepository->getAllInChallenge($challenge, [PlaceInChallenge::class]) as $guess) {
foreach ($this->guessRepository->getAllInChallenge($challenge, ['place_in_challange']) as $guess) {
\Container::$persistentDataManager->deleteFromDb($guess);
}
+4 -4
View File
@@ -40,7 +40,7 @@ class ChallengeRepository
$select = new Select(\Container::$dbConnection);
$select->innerJoin('user_in_challenge', ['challenge', 'id'], '=', ['user_in_challenge', 'challenge_id']);
$select->innerJoin('users', ['users', 'id'], '=', ['user_in_challenge', 'user_id']);
$select->where('user_id', '=', $user->getId());
$select->where(['user_in_challenge', 'user_id'], '=', $user->getId());
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Challenge::class);
}
@@ -50,8 +50,8 @@ class ChallengeRepository
$select = new Select(\Container::$dbConnection);
$select->innerJoin('user_in_challenge', ['challenge', 'id'], '=', ['user_in_challenge', 'challenge_id']);
$select->innerJoin('users', ['users', 'id'], '=', ['user_in_challenge', 'user_id']);
$select->where('user_id', '=', $user->getId());
$select->where('is_owner', '=', true);
$select->where(['user_in_challenge', 'user_id'], '=', $user->getId());
$select->where(['user_in_challenge', 'is_owner'], '=', true);
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Challenge::class);
}
@@ -60,7 +60,7 @@ class ChallengeRepository
{
$select = new Select(\Container::$dbConnection);
$select->innerJoin('place_in_challenge', ['challenges', 'id'], '=', ['place_in_challenge', 'challenge_id']);
$select->where('place_id', '=', $place->getId());
$select->where(['place_in_challenge', 'place_id'], '=', $place->getId());
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Challenge::class);
}
+12 -12
View File
@@ -23,7 +23,7 @@ class GuessRepository
$select = new Select(\Container::$dbConnection);
$select->innerJoin('place_in_challenge', ['place_in_challenge', 'id'], '=', ['guesses', 'place_in_challenge_id']);
$select->where('user_id', '=', $user->getId());
$select->where('challenge_id', '=', $challenge->getId());
$select->where(['place_in_challenge', 'challenge_id'], '=', $challenge->getId());
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Guess::class);
}
@@ -33,8 +33,8 @@ class GuessRepository
$select = new Select(\Container::$dbConnection);
$select->innerJoin('place_in_challenge', ['place_in_challenge', 'id'], '=', ['guesses', 'place_in_challenge_id']);
$select->where('user_id', '=', $user->getId());
$select->where('challenge_id', '=', $challenge->getId());
$select->where('place_id', '=', $place->getId());
$select->where(['place_in_challenge', 'challenge_id'], '=', $challenge->getId());
$select->where(['place_in_challenge', 'place_id'], '=', $place->getId());
return \Container::$persistentDataManager->selectFromDb($select, Guess::class);
}
@@ -44,8 +44,8 @@ class GuessRepository
$select = new Select(\Container::$dbConnection);
$select->innerJoin('place_in_challenge', ['place_in_challenge', 'id'], '=', ['guesses', 'place_in_challenge_id']);
$select->where('user_id', '=', $userId);
$select->where('challenge_id', '=', $challenge->getId());
$select->orderBy('round');
$select->where(['place_in_challenge', 'challenge_id'], '=', $challenge->getId());
$select->orderBy(['place_in_challenge', 'round']);
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Guess::class);
}
@@ -53,13 +53,13 @@ class GuessRepository
public function getAllInChallenge(Challenge $challenge, array $withRelations = []): Generator
{
if (count($withRelations)) {
$necessaryRelations = [PlaceInChallenge::class];
$necessaryRelations = ['place_in_challenge'];
$withRelations = array_unique(array_merge($withRelations, $necessaryRelations));
}
$select = new Select(\Container::$dbConnection);
$select->where('challenge_id', '=', $challenge->getId());
$select->orderBy('round');
$select->where(['guesses__place_in_challenge', 'challenge_id'], '=', $challenge->getId());
$select->orderBy(['guesses__place_in_challenge', 'round']);
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Guess::class, true, $withRelations);
}
@@ -67,13 +67,13 @@ class GuessRepository
public function getAllInChallengeByRound(int $round, Challenge $challenge, array $withRelations = []): Generator
{
if (count($withRelations)) {
$necessaryRelations = [PlaceInChallenge::class];
$necessaryRelations = ['place_in_challenge'];
$withRelations = array_unique(array_merge($withRelations, $necessaryRelations));
}
$select = new Select(\Container::$dbConnection);
$select->where('challenge_id', '=', $challenge->getId());
$select->where('round', '=', $round);
$select->where(['guesses__place_in_challenge', 'challenge_id'], '=', $challenge->getId());
$select->where(['guesses__place_in_challenge', 'round'], '=', $round);
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Guess::class, true, $withRelations);
}
@@ -82,7 +82,7 @@ class GuessRepository
{
$select = new Select(\Container::$dbConnection);
$select->innerJoin('place_in_challenge', ['place_in_challenge', 'id'], '=', ['guesses', 'place_in_challenge_id']);
$select->where('place_id', '=', $place->getId());
$select->where(['place_in_challenge', 'place_id'], '=', $place->getId());
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Guess::class);
}
+1 -1
View File
@@ -22,7 +22,7 @@ class MapRepository
$select = new Select(\Container::$dbConnection);
$select->innerJoin('places', ['maps', 'id'], '=', ['places', 'map_id']);
$select->innerJoin('place_in_challenge', ['places', 'id'], '=', ['place_in_challenge', 'place_id']);
$select->where('challenge_id', '=', $challenge->getId());
$select->where(['place_in_challenge', 'challenge_id'], '=', $challenge->getId());
$select->limit(1);
return \Container::$persistentDataManager->selectFromDb($select, Map::class);
+8 -8
View File
@@ -109,8 +109,8 @@ class PlaceRepository
// count the places never visited
$selectUnvisited = new Select(\Container::$dbConnection, 'places');
$selectUnvisited->leftJoin($selectPlacesByCurrentUser, ['places', 'id'], '=', ['places_by_current_user', 'place_id']);
$selectUnvisited->where('map_id', '=', $mapId);
$selectUnvisited->where('last_time', '=', null);
$selectUnvisited->where(['places', 'map_id'], '=', $mapId);
$selectUnvisited->where(['places_by_current_user', 'last_time'], '=', null);
$numberOfUnvisitedPlaces = $selectUnvisited->count();
// look for as many new places as possible but maximum $n
@@ -140,11 +140,11 @@ class PlaceRepository
// count places that were visited at least once
$selectOldPlaces = new Select(\Container::$dbConnection, 'places');
$selectOldPlaces->innerJoin($selectPlacesByCurrentUser, ['places', 'id'], '=', ['places_by_current_user', 'place_id']);
$selectOldPlaces->where('map_id', '=', $mapId);
$selectOldPlaces->where(['places', 'map_id'], '=', $mapId);
$numberOfOldPlaces = $selectOldPlaces->count();
// set order by datetime, oldest first
$selectOldPlaces->orderBy('last_time');
$selectOldPlaces->orderBy(['places_by_current_user', 'last_time']);
// selection algorithm with preference (weighting) for older places using Box-Muller transform
$pickGaussianRandomInt = function($numberOfPlaces) {
@@ -174,8 +174,8 @@ class PlaceRepository
{
$select = new Select(\Container::$dbConnection);
$select->innerJoin('place_in_challenge', ['places', 'id'], '=', ['place_in_challenge', 'place_id']);
$select->where('challenge_id', '=', $challenge->getId());
$select->orderBy('round');
$select->where(['place_in_challenge', 'challenge_id'], '=', $challenge->getId());
$select->orderBy(['place_in_challenge', 'round']);
$select->limit(1, $round);
return \Container::$persistentDataManager->selectFromDb($select, Place::class);
@@ -185,8 +185,8 @@ class PlaceRepository
{
$select = new Select(\Container::$dbConnection);
$select->innerJoin('place_in_challenge', ['places', 'id'], '=', ['place_in_challenge', 'place_id']);
$select->where('challenge_id', '=', $challenge->getId());
$select->orderBy('round');
$select->where(['place_in_challenge', 'challenge_id'], '=', $challenge->getId());
$select->orderBy(['place_in_challenge', 'round']);
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, Place::class);
}
+3 -3
View File
@@ -29,7 +29,7 @@ class UserInChallengeRepository
$select = new Select(\Container::$dbConnection);
$select->where('challenge_id', '=', $challenge->getId());
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, UserInChallenge::class, true, [User::class]);
yield from \Container::$persistentDataManager->selectMultipleFromDb($select, UserInChallenge::class, true, ['user']);
}
public function getByUserIdAndChallenge(int $userId, Challenge $challenge): ?UserInChallenge
@@ -44,7 +44,7 @@ class UserInChallengeRepository
public function getByUserIdAndToken(int $userId, string $token_str, array $withRelations = []): ?UserInChallenge
{
if (count($withRelations)) {
$necessaryRelations = [Challenge::class];
$necessaryRelations = ['challange'];
$withRelations = array_unique(array_merge($withRelations, $necessaryRelations));
}
@@ -57,7 +57,7 @@ class UserInChallengeRepository
$select = new Select(\Container::$dbConnection);
$select->where('user_id', '=', $userId);
$select->where('token', '=', $token);
$select->where(['user_in_challenge__challenge', 'token'], '=', $token);
return \Container::$persistentDataManager->selectFromDb($select, UserInChallenge::class, true, $withRelations);
}
+5 -5
View File
@@ -9,12 +9,12 @@
<?php if ($user['password'] !== null && $user['google_sub'] !== null): ?>
<p class="justify small">Please confirm your identity with your password or with Google to modify your account.</p>
<div class="inputWithButton">
<input type="password" class="text name="password" placeholder="Current password" required minlength="6" autofocus><!--
<input type="password" class="text name="password" placeholder="Current password" autocomplete="current-password" required minlength="6" autofocus><!--
--><button id="authenticateWithGoogleButton" class="yellow" type="button">Google</button>
</div>
<?php elseif ($user['password'] !== null): ?>
<p class="justify small">Please confirm your identity with your password to modify your account.</p>
<input type="password" class="text big fullWidth" name="password" placeholder="Current password" required minlength="6" autofocus>
<input type="password" class="text big fullWidth" name="password" placeholder="Current password" autocomplete="current-password" required minlength="6" autofocus>
<?php elseif ($user['google_sub'] !== null): ?>
<p class="justify small">Please confirm your identity with Google to modify your account.</p>
<div class="inputWithButton">
@@ -24,9 +24,9 @@
<?php endif; ?>
<hr>
<?php /* TODO: disabled for the time being, email modification should be implemented */ ?>
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" value="<?= $user['email'] ?>" disabled>
<input type="password" class="text big fullWidth marginTop" name="password_new" placeholder="New password" minlength="6">
<input type="password" class="text big fullWidth marginTop" name="password_new_confirm" placeholder="New password confirmation" minlength="6">
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" autocomplete="username" value="<?= $user['email'] ?>" disabled>
<input type="password" class="text big fullWidth marginTop" name="password_new" placeholder="New password" autocomplete="new-password" minlength="6">
<input type="password" class="text big fullWidth marginTop" name="password_new_confirm" placeholder="New password confirmation" autocomplete="new-password" minlength="6">
<p id="accountFormError" class="formError justify marginTop"></p>
<div class="right marginTop">
<button type="submit" name="submit" disabled>Save</button>
+3 -2
View File
@@ -7,15 +7,16 @@
<div class="box">
<form id="deleteAccountForm" action="/account/delete" method="post" data-redirect-on-success="/">
<p class="justify marginBottom">Are you sure you want to delete your account? This cannot be undone!</p>
<input type="email" style="display: none;" name="email" autocomplete="username" value="<?= $user['email'] ?>">
<?php if ($user['password'] !== null && $user['google_sub'] !== null): ?>
<p class="justify small">Please confirm your identity with your password or with Google to delete your account.</p>
<div class="inputWithButton">
<input type="password" class="text" name="password" placeholder="Current password" required minlength="6" autofocus><!--
<input type="password" class="text" name="password" placeholder="Current password" autocomplete="current-password" required minlength="6" autofocus><!--
--><button id="authenticateWithGoogleButton" class="yellow" type="button">Google</button>
</div>
<?php elseif ($user['password'] !== null): ?>
<p class="justify small">Please confirm your identity with your password to delete your account.</p>
<input type="password" class="text big fullWidth" name="password" placeholder="Current password" required minlength="6" autofocus>
<input type="password" class="text big fullWidth" name="password" placeholder="Current password" autocomplete="current-password" required minlength="6" autofocus>
<?php elseif ($user['google_sub'] !== null): ?>
<p class="justify small">Please confirm your identity with Google to delete your account.</p>
<div class="inputWithButton">
+2 -2
View File
@@ -4,8 +4,8 @@
<h2>Login</h2>
<div class="box">
<form id="loginForm" action="/login" method="post" data-redirect-on-success="<?= $redirectUrl ?>">
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" required autofocus>
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" required minlength="6">
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" autocomplete="username" required autofocus>
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" autocomplete="current-password" required minlength="6">
<p id="loginFormError" class="formError justify marginTop"></p>
<div class="right marginTop">
<button type="submit">Login</button>
+1 -1
View File
@@ -6,7 +6,7 @@
<h2>Request password reset</h2>
<div class="box">
<form id="passwordResetForm" action="/password/requestReset" method="post" data-redirect-on-success="/password/requestReset/success">
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" value="<?= isset($email) ? $email : '' ?>" required autofocus>
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" autocomplete="username" value="<?= isset($email) ? $email : '' ?>" required autofocus>
<?php if (!empty($_ENV['RECAPTCHA_SITEKEY'])): ?>
<div class="marginTop">
<div class="g-recaptcha" data-sitekey="<?= $_ENV['RECAPTCHA_SITEKEY'] ?>"></div>
+3 -3
View File
@@ -5,9 +5,9 @@
<div class="box">
<?php if ($success) : ?>
<form id="resetPasswordForm" action="/password/reset/<?= $token ?>" method="post" data-redirect-on-success="<?= $redirectUrl ?>">
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" value="<?= $email ?>" disabled>
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" required minlength="6" autofocus>
<input type="password" class="text big fullWidth marginTop" name="password_confirm" placeholder="Password confirmation" required minlength="6">
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" autocomplete="username" value="<?= $email ?>" disabled>
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" autocomplete="new-password" required minlength="6" autofocus>
<input type="password" class="text big fullWidth marginTop" name="password_confirm" placeholder="Password confirmation" autocomplete="new-password" required minlength="6">
<p id="resetPasswordFormError" class="formError justify marginTop"></p>
<div class="right">
<button class="marginTop" type="submit">Reset password</button>
+5 -5
View File
@@ -9,12 +9,12 @@
<form id="signupForm" action="/signup" method="post" data-redirect-on-success="/signup/success">
<?php if (isset($email)): ?>
<p class="justify">No user found with the given email address. Sign up with one click!</p>
<input type="email" class="text big fullWidth marginTop" name="email" placeholder="Email address" value="<?= $email ?>" required>
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password confirmation" required minlength="6" autofocus>
<input type="email" class="text big fullWidth marginTop" name="email" placeholder="Email address" autocomplete="username" value="<?= $email ?>" required>
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password confirmation" autocomplete="new-password" required minlength="6" autofocus>
<?php else: ?>
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" required autofocus>
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" required minlength="6">
<input type="password" class="text big fullWidth marginTop" name="password_confirm" placeholder="Password confirmation" minlength="6">
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" autocomplete="username" required autofocus>
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" autocomplete="new-password" required minlength="6">
<input type="password" class="text big fullWidth marginTop" name="password_confirm" placeholder="Password confirmation" autocomplete="new-password" minlength="6">
<?php endif; ?>
<?php if (!empty($_ENV['RECAPTCHA_SITEKEY'])): ?>
<div class="marginTop">
+8 -13
View File
@@ -4,6 +4,7 @@ use SokoWeb\Response\HttpResponse;
use SokoWeb\Routing\RouteCollection;
use SokoWeb\Session\DatabaseSessionHandler;
use SokoWeb\Request\Request;
use SokoWeb\Request\Session;
use MapGuesser\Controller\MapsController;
use MapGuesser\Controller\HomeController;
use MapGuesser\Controller\LoginController;
@@ -90,27 +91,21 @@ Container::$routeCollection->group('admin', function (RouteCollection $routeColl
});
if (isset($_COOKIE['COOKIES_CONSENT'])) {
Container::$sessionHandler = new DatabaseSessionHandler(Container::$dbConnection);
Container::$sessionHandler = new DatabaseSessionHandler(
Container::$dbConnection,
'sessions',
new DateTime('-7 days')
);
session_set_save_handler(Container::$sessionHandler, true);
session_start([
'gc_probability' => 0, // old sessions are deleted by MaintainDatabaseCommand
'cookie_lifetime' => 604800,
'cookie_lifetime' => 0,
'cookie_path' => '/',
'cookie_httponly' => true,
'cookie_samesite' => 'Lax'
]);
if (isset($_COOKIE[session_name()])) {
// extend session cookie lifetime is cookie already exists
setcookie(session_name(), session_id(), [
'expires' => time() + 604800,
'path' => '/',
'httponly' => true,
'samesite' => 'Lax'
]);
}
// this is needed to handle old type of session IDs
if (!Container::$sessionHandler->validateId(session_id())) {
session_regenerate_id(true);
@@ -124,7 +119,7 @@ Container::$request = new Request(
$_GET,
$_POST,
getallheaders(),
$_SESSION,
new Session($_SESSION),
new UserRepository()
);