Compare commits

..

5 Commits

7 changed files with 19 additions and 38 deletions

View File

@ -10,7 +10,7 @@
}
],
"require": {
"esoko/soko-web": "0.4",
"esoko/soko-web": "0.6",
"fzaninotto/faker": "^1.9"
},
"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",
"This file is @generated automatically"
],
"content-hash": "5e355d5efeb34e7e0ad2a69b1ec109d6",
"content-hash": "fd65225819ba36427cdc6a925b417bd1",
"packages": [
{
"name": "esoko/soko-web",
"version": "v0.4",
"version": "0.6",
"source": {
"type": "git",
"url": "https://git.esoko.eu/esoko/soko-web.git",
"reference": "948b36c80d324e07339a543d97b9e629487f3a45"
"reference": "5e0579463cf0f4203c46e0d4f9c09cd283dbf0b8"
},
"require": {
"phpmailer/phpmailer": "^6.8",
@ -33,7 +33,7 @@
"GNU GPL 3.0"
],
"description": "Lightweight web framework",
"time": "2023-04-16T18:52:06+00:00"
"time": "2023-04-19T21:35:03+00:00"
},
{
"name": "fzaninotto/faker",

View File

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

View File

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

View File

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

11
views/error/500.php Normal file
View File

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