Compare commits

..

No commits in common. "0546e200119069164456723478da579efdae58c0" and "6cb4e06accb8b2e838e06e44be83b9399aaf0cbd" have entirely different histories.

7 changed files with 38 additions and 19 deletions

View File

@ -10,7 +10,7 @@
} }
], ],
"require": { "require": {
"esoko/soko-web": "0.6", "esoko/soko-web": "0.4",
"fzaninotto/faker": "^1.9" "fzaninotto/faker": "^1.9"
}, },
"require-dev": { "require-dev": {

8
composer.lock generated
View File

@ -4,15 +4,15 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "fd65225819ba36427cdc6a925b417bd1", "content-hash": "5e355d5efeb34e7e0ad2a69b1ec109d6",
"packages": [ "packages": [
{ {
"name": "esoko/soko-web", "name": "esoko/soko-web",
"version": "0.6", "version": "v0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.esoko.eu/esoko/soko-web.git", "url": "https://git.esoko.eu/esoko/soko-web.git",
"reference": "5e0579463cf0f4203c46e0d4f9c09cd283dbf0b8" "reference": "948b36c80d324e07339a543d97b9e629487f3a45"
}, },
"require": { "require": {
"phpmailer/phpmailer": "^6.8", "phpmailer/phpmailer": "^6.8",
@ -33,7 +33,7 @@
"GNU GPL 3.0" "GNU GPL 3.0"
], ],
"description": "Lightweight web framework", "description": "Lightweight web framework",
"time": "2023-04-19T21:35:03+00:00" "time": "2023-04-16T18:52:06+00:00"
}, },
{ {
"name": "fzaninotto/faker", "name": "fzaninotto/faker",

View File

@ -346,6 +346,8 @@ class LoginController
$user->setPlainPassword($this->request->post('password')); $user->setPlainPassword($this->request->post('password'));
$user->setCreatedDate(new DateTime()); $user->setCreatedDate(new DateTime());
\Container::$dbConnection->startTransaction();
$this->pdm->saveToDb($user); $this->pdm->saveToDb($user);
$token = bin2hex(random_bytes(16)); $token = bin2hex(random_bytes(16));
@ -357,6 +359,8 @@ class LoginController
$this->pdm->saveToDb($confirmation); $this->pdm->saveToDb($confirmation);
\Container::$dbConnection->commit();
$this->sendConfirmationEmail($user->getEmail(), $token, $user->getCreatedDate()); $this->sendConfirmationEmail($user->getEmail(), $token, $user->getCreatedDate());
$this->request->session()->delete('tmp_user_data'); $this->request->session()->delete('tmp_user_data');
@ -428,6 +432,8 @@ class LoginController
return new HtmlContent('login/activate'); return new HtmlContent('login/activate');
} }
\Container::$dbConnection->startTransaction();
$this->pdm->deleteFromDb($confirmation); $this->pdm->deleteFromDb($confirmation);
$user = $this->userRepository->getById($confirmation->getUserId()); $user = $this->userRepository->getById($confirmation->getUserId());
@ -435,6 +441,8 @@ class LoginController
$this->pdm->saveToDb($user); $this->pdm->saveToDb($user);
\Container::$dbConnection->commit();
$this->request->setUser($user); $this->request->setUser($user);
$this->deleteRedirectUrl(); $this->deleteRedirectUrl();
@ -454,6 +462,8 @@ class LoginController
return new HtmlContent('login/cancel', ['success' => false]); return new HtmlContent('login/cancel', ['success' => false]);
} }
\Container::$dbConnection->startTransaction();
$this->pdm->deleteFromDb($confirmation); $this->pdm->deleteFromDb($confirmation);
$user = $this->userRepository->getById($confirmation->getUserId()); $user = $this->userRepository->getById($confirmation->getUserId());
@ -464,6 +474,8 @@ class LoginController
$this->pdm->deleteFromDb($user); $this->pdm->deleteFromDb($user);
\Container::$dbConnection->commit();
return new HtmlContent('login/cancel', ['success' => true]); return new HtmlContent('login/cancel', ['success' => true]);
} }
@ -529,12 +541,16 @@ class LoginController
$passwordResetter->setToken($token); $passwordResetter->setToken($token);
$passwordResetter->setExpiresDate($expires); $passwordResetter->setExpiresDate($expires);
\Container::$dbConnection->startTransaction();
if ($existingResetter !== null) { if ($existingResetter !== null) {
$this->pdm->deleteFromDb($existingResetter); $this->pdm->deleteFromDb($existingResetter);
} }
$this->pdm->saveToDb($passwordResetter); $this->pdm->saveToDb($passwordResetter);
\Container::$dbConnection->commit();
$this->sendPasswordResetEmail($user->getEmail(), $token, $expires); $this->sendPasswordResetEmail($user->getEmail(), $token, $expires);
return new JsonContent(['success' => true]); return new JsonContent(['success' => true]);
@ -575,6 +591,8 @@ class LoginController
return new JsonContent(['error' => ['errorText' => 'The given passwords do not match.']]); return new JsonContent(['error' => ['errorText' => 'The given passwords do not match.']]);
} }
\Container::$dbConnection->startTransaction();
$this->pdm->deleteFromDb($resetter); $this->pdm->deleteFromDb($resetter);
$user = $this->userRepository->getById($resetter->getUserId()); $user = $this->userRepository->getById($resetter->getUserId());
@ -582,6 +600,8 @@ class LoginController
$this->pdm->saveToDb($user); $this->pdm->saveToDb($user);
\Container::$dbConnection->commit();
$this->request->setUser($user); $this->request->setUser($user);
$this->deleteRedirectUrl(); $this->deleteRedirectUrl();

View File

@ -104,6 +104,8 @@ class MapAdminController implements IAuthenticationRequired, ISecured
{ {
$mapId = (int) $this->request->query('mapId'); $mapId = (int) $this->request->query('mapId');
\Container::$dbConnection->startTransaction();
if ($mapId) { if ($mapId) {
$map = $this->mapRepository->getById($mapId); $map = $this->mapRepository->getById($mapId);
} else { } else {
@ -184,6 +186,8 @@ class MapAdminController implements IAuthenticationRequired, ISecured
$this->pdm->saveToDb($map); $this->pdm->saveToDb($map);
\Container::$dbConnection->commit();
return new JsonContent(['mapId' => $map->getId(), 'added' => $addedIds]); return new JsonContent(['mapId' => $map->getId(), 'added' => $addedIds]);
} }
@ -193,10 +197,14 @@ class MapAdminController implements IAuthenticationRequired, ISecured
$map = $this->mapRepository->getById($mapId); $map = $this->mapRepository->getById($mapId);
\Container::$dbConnection->startTransaction();
$this->deletePlaces($map); $this->deletePlaces($map);
$this->pdm->deleteFromDb($map); $this->pdm->deleteFromDb($map);
\Container::$dbConnection->commit();
return new JsonContent(['success' => true]); return new JsonContent(['success' => true]);
} }

View File

@ -199,6 +199,8 @@ class UserController implements IAuthenticationRequired
return new JsonContent(['error' => ['errorText' => $error]]); return new JsonContent(['error' => ['errorText' => $error]]);
} }
\Container::$dbConnection->startTransaction();
$userConfirmation = $this->userConfirmationRepository->getByUser($user); $userConfirmation = $this->userConfirmationRepository->getByUser($user);
if ($userConfirmation !== null) { if ($userConfirmation !== null) {
$this->pdm->deleteFromDb($userConfirmation); $this->pdm->deleteFromDb($userConfirmation);
@ -223,6 +225,8 @@ class UserController implements IAuthenticationRequired
$this->pdm->deleteFromDb($user); $this->pdm->deleteFromDb($user);
\Container::$dbConnection->commit();
$this->request->session()->delete('authenticated_with_google_until'); $this->request->session()->delete('authenticated_with_google_until');
return new JsonContent(['success' => true]); return new JsonContent(['success' => true]);

View File

@ -1,11 +0,0 @@
@extends(templates/layout_normal)
@section(main)
<h2>500 | Internal server error</h2>
<p>An error occured during processing your request. <a href="<?= Container::$routeCollection->getRoute('home')->generateLink() ?>" title="<?= $_ENV['APP_NAME'] ?>">Back to start.</a></p>
<?php if (isset($exceptionToPrint)): ?>
<pre class="marginTop">
<?= $exceptionToPrint ?>
</pre>
<?php endif; ?>
@endsection

View File

@ -137,13 +137,11 @@ $appConfig = [
'antiCsrfTokenErrorResponse' => ['error' => 'no_valid_anti_csrf_token'], 'antiCsrfTokenErrorResponse' => ['error' => 'no_valid_anti_csrf_token'],
'antiCsrfTokenExceptions' => [], 'antiCsrfTokenExceptions' => [],
'loginRouteId' => 'login', 'loginRouteId' => 'login',
'error404View' => 'error/404', 'error404View' => 'error/404'
'error500View' => 'error/500'
]; ];
$httpReponse = new HttpResponse( $httpReponse = new HttpResponse(
Container::$request, Container::$request,
Container::$dbConnection,
Container::$routeCollection, Container::$routeCollection,
$appConfig, $appConfig,
$_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_METHOD'],