From 46ea01efe11ce3845c51011dbc22f358cf68f8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Tue, 18 Apr 2023 23:20:29 +0200 Subject: [PATCH 1/5] update soko-web to 0.5 --- composer.json | 2 +- composer.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index cf8a1b3..1c356ae 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "esoko/soko-web": "0.4", + "esoko/soko-web": "0.5", "firebase/php-jwt": "^6.4" }, "require-dev": { diff --git a/composer.lock b/composer.lock index bd27b77..b75ddce 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "f7786e07bcb0373560ae67549fa28f0b", + "content-hash": "05dba423c5e5dd40b5a7b9d4180d3673", "packages": [ { "name": "esoko/soko-web", - "version": "v0.4", + "version": "v0.5", "source": { "type": "git", "url": "https://git.esoko.eu/esoko/soko-web.git", - "reference": "948b36c80d324e07339a543d97b9e629487f3a45" + "reference": "3893ed22316e84aa4ffab7fbb3d5e823b928b001" }, "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-18T21:17:08+00:00" }, { "name": "firebase/php-jwt", From 4d5e982370722157a8bb495d8d2dd2ff093a2550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Tue, 18 Apr 2023 23:25:38 +0200 Subject: [PATCH 2/5] pass dbConnection to HttpResponse --- web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/web.php b/web.php index a9cb13e..156f154 100644 --- a/web.php +++ b/web.php @@ -113,6 +113,7 @@ $appConfig = [ $httpReponse = new HttpResponse( Container::$request, + Container::$dbConnection, Container::$routeCollection, $appConfig, $_SERVER['REQUEST_METHOD'], From a7997429b7ff503dae55db9a182c76e145a23381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Tue, 18 Apr 2023 23:25:59 +0200 Subject: [PATCH 3/5] add view for error 500 --- views/error/500.php | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 views/error/500.php diff --git a/views/error/500.php b/views/error/500.php new file mode 100644 index 0000000..2ccaeec --- /dev/null +++ b/views/error/500.php @@ -0,0 +1,11 @@ +@extends(templates/layout_normal) + +@section(main) +

500 | Internal server error

+

An error occured during processing your request. Back to start.

+ +
+
+            
+ +@endsection From 617ae903aed0896cec12a1c2790f394f0d7179ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Tue, 18 Apr 2023 23:21:06 +0200 Subject: [PATCH 4/5] add error view 500 to app config --- web.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web.php b/web.php index 156f154..64d46f7 100644 --- a/web.php +++ b/web.php @@ -108,7 +108,8 @@ $appConfig = [ 'antiCsrfTokenErrorResponse' => ['error' => 'no_valid_anti_csrf_token'], 'antiCsrfTokenExceptions' => ['/oauth/token'], 'loginRouteId' => 'login', - 'error404View' => 'error/404' + 'error404View' => 'error/404', + 'error500View' => 'error/500' ]; $httpReponse = new HttpResponse( From b4cfa7aab2e077b8c280bc0270b38aa53f13f749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Tue, 18 Apr 2023 23:21:53 +0200 Subject: [PATCH 5/5] remove unnecessary startTransaction and commit calls --- src/Controller/LoginController.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index a723817..94e7c82 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -226,16 +226,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]); @@ -275,8 +271,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()); @@ -284,8 +278,6 @@ class LoginController $this->pdm->saveToDb($user); - \Container::$dbConnection->commit(); - $this->request->setUser($user); $this->deleteRedirectUrl();