From b958a2f5b30a3d3e9352ea01c99cabe6e87190c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Tue, 2 May 2023 00:02:38 +0200 Subject: [PATCH] rename routes --- src/Controller/LoginController.php | 14 ++--- src/Controller/OAuthController.php | 8 +-- views/communities/community.php | 2 +- views/communities/community_currencies.php | 6 +- views/communities/community_edit.php | 4 +- views/communities/community_members.php | 6 +- views/communities/community_settings.php | 6 +- views/communities/currency_exchange_rates.php | 6 +- views/communities/transaction_edit.php | 2 +- views/home.php | 2 +- views/login/login.php | 4 +- views/login/password_reset_request.php | 2 +- views/login/reset_password.php | 4 +- web.php | 59 +++++++++---------- 14 files changed, 62 insertions(+), 63 deletions(-) diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index cca513f..4eaa2be 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -53,7 +53,7 @@ class LoginController $oAuth = new GoogleOAuth(new Request()); $url = $oAuth->getDialogUrl( $state, - \Container::$request->getBase() . \Container::$routeCollection->getRoute('login-google-action')->generateLink(), + \Container::$request->getBase() . \Container::$routeCollection->getRoute('login.google-action')->generateLink(), $nonce ); @@ -106,7 +106,7 @@ class LoginController return new JsonContent([ 'error' => [ 'errorText' => 'No user found with the given email address / username or the given password is wrong. You can request password reset!' + \Container::$routeCollection->getRoute('password.requestReset')->generateLink(['email' => \Container::$request->post('email')]) . '" title="Request password reset">request password reset!' ] ]); } @@ -119,7 +119,7 @@ class LoginController public function loginWithGoogle() { - $defaultError = 'Authentication with Google failed. Please try again!'; + $defaultError = 'Authentication with Google failed. Please try again!'; if (\Container::$request->user() !== null) { $this->deleteRedirectUrl(); @@ -133,7 +133,7 @@ class LoginController $oAuth = new GoogleOAuth(new Request()); $tokenData = $oAuth->getToken( \Container::$request->query('code'), - \Container::$request->getBase() . \Container::$routeCollection->getRoute('login-google-action')->generateLink() + \Container::$request->getBase() . \Container::$routeCollection->getRoute('login.google-action')->generateLink() ); if (!isset($tokenData['id_token'])) { @@ -246,7 +246,7 @@ class LoginController if ($resetter === null || $resetter->getExpiresDate() < new DateTime()) { return new JsonContent([ 'redirect' => [ - 'target' => \Container::$routeCollection->getRoute('password-reset')->generateLink(['token' => $token]) + 'target' => \Container::$routeCollection->getRoute('password.reset')->generateLink(['token' => $token]) ] ]); } @@ -281,10 +281,10 @@ class LoginController $mail = new Mail(); $mail->addRecipient($email); $mail->setSubject($_ENV['APP_NAME'] . ' - Password reset'); - $mail->setBodyFromTemplate('password-reset', [ + $mail->setBodyFromTemplate('password.reset', [ 'EMAIL' => $email, 'RESET_LINK' => \Container::$request->getBase() . - \Container::$routeCollection->getRoute('password-reset')->generateLink(['token' => $token]), + \Container::$routeCollection->getRoute('password.reset')->generateLink(['token' => $token]), 'EXPIRES' => $expires->format('Y-m-d H:i T') ]); $mail->send(); diff --git a/src/Controller/OAuthController.php b/src/Controller/OAuthController.php index ee41154..48b318e 100644 --- a/src/Controller/OAuthController.php +++ b/src/Controller/OAuthController.php @@ -104,10 +104,10 @@ class OAuthController { return new JsonContent([ 'issuer' => $_ENV['APP_URL'], - 'authorization_endpoint' => \Container::$request->getBase() . \Container::$routeCollection->getRoute('oauth-auth')->generateLink(), - 'token_endpoint' => \Container::$request->getBase() . \Container::$routeCollection->getRoute('oauth-token')->generateLink(), - 'userinfo_endpoint' => \Container::$request->getBase() . \Container::$routeCollection->getRoute('oauth-userinfo')->generateLink(), - 'jwks_uri' => \Container::$request->getBase() . \Container::$routeCollection->getRoute('oauth-certs')->generateLink(), + 'authorization_endpoint' => \Container::$request->getBase() . \Container::$routeCollection->getRoute('oauth.auth')->generateLink(), + 'token_endpoint' => \Container::$request->getBase() . \Container::$routeCollection->getRoute('oauth.token')->generateLink(), + 'userinfo_endpoint' => \Container::$request->getBase() . \Container::$routeCollection->getRoute('oauth.userinfo')->generateLink(), + 'jwks_uri' => \Container::$request->getBase() . \Container::$routeCollection->getRoute('oauth.certs')->generateLink(), 'response_types_supported' => [ 'code', diff --git a/views/communities/community.php b/views/communities/community.php index 13ce2dc..8055113 100644 --- a/views/communities/community.php +++ b/views/communities/community.php @@ -4,7 +4,7 @@

getName() ?> - [edit] + [edit]

diff --git a/views/communities/community_currencies.php b/views/communities/community_currencies.php index ab19f0b..5b2f5ea 100644 --- a/views/communities/community_currencies.php +++ b/views/communities/community_currencies.php @@ -18,8 +18,8 @@ -
-
+
+
@@ -35,7 +35,7 @@ -
+
diff --git a/views/communities/community_edit.php b/views/communities/community_edit.php index 07fbd0b..6614a0e 100644 --- a/views/communities/community_edit.php +++ b/views/communities/community_edit.php @@ -12,8 +12,8 @@
getRoute('community-edit-action')->generateLink(['communityId' => $community->getId()]) : - Container::$routeCollection->getRoute('community-new-action')->generateLink(); + Container::$routeCollection->getRoute('community.edit-action')->generateLink(['communityId' => $community->getId()]) : + Container::$routeCollection->getRoute('community.new-action')->generateLink(); ?>
diff --git a/views/communities/community_members.php b/views/communities/community_members.php index 0397cbd..4646804 100644 --- a/views/communities/community_members.php +++ b/views/communities/community_members.php @@ -23,8 +23,8 @@ getUserId() !== Container::$request->user()->getUniqueId(); ?> -
-
+
+
getUser()->getDisplayName() ?> @@ -40,7 +40,7 @@ -
+
@@ -44,7 +44,7 @@ -
+
diff --git a/views/communities/transaction_edit.php b/views/communities/transaction_edit.php index 152d479..7539303 100644 --- a/views/communities/transaction_edit.php +++ b/views/communities/transaction_edit.php @@ -47,7 +47,7 @@
-
+
@endsection diff --git a/views/home.php b/views/home.php index f88aa66..e2e81a9 100644 --- a/views/home.php +++ b/views/home.php @@ -5,7 +5,7 @@

Communities - [new] + [new]

0): ?> diff --git a/views/login/login.php b/views/login/login.php index cd98f3b..1d5fe4d 100644 --- a/views/login/login.php +++ b/views/login/login.php @@ -10,10 +10,10 @@
-

Forgot your password?

+

Forgot your password?


diff --git a/views/login/password_reset_request.php b/views/login/password_reset_request.php index 779aa71..e3ea761 100644 --- a/views/login/password_reset_request.php +++ b/views/login/password_reset_request.php @@ -5,7 +5,7 @@ @section(main)

Request password reset

-
+
diff --git a/views/login/reset_password.php b/views/login/reset_password.php index b7059d4..69d3875 100644 --- a/views/login/reset_password.php +++ b/views/login/reset_password.php @@ -4,7 +4,7 @@

Reset password

- + @@ -14,7 +14,7 @@
-

Confirming your identity failed. Please check the link you entered, or retry requesting password reset!

+

Confirming your identity failed. Please check the link you entered, or retry requesting password reset!

@endsection diff --git a/web.php b/web.php index e5b3421..125deca 100644 --- a/web.php +++ b/web.php @@ -27,26 +27,25 @@ if (!empty($_ENV['DEV'])) { Container::$routeCollection = new RouteCollection(); Container::$routeCollection->get('home', '', [HomeController::class, 'getHome']); -Container::$routeCollection->get('startSession', 'startSession.json', [HomeController::class, 'startSession']); Container::$routeCollection->group('login', function (RouteCollection $routeCollection) { $routeCollection->get('login', '', [LoginController::class, 'getLoginForm']); $routeCollection->post('login-action', '', [LoginController::class, 'login']); - $routeCollection->get('login-google', 'google', [LoginController::class, 'getGoogleLoginRedirect']); - $routeCollection->get('login-google-action', 'google/code', [LoginController::class, 'loginWithGoogle']); + $routeCollection->get('login.google', 'google', [LoginController::class, 'getGoogleLoginRedirect']); + $routeCollection->get('login.google-action', 'google/code', [LoginController::class, 'loginWithGoogle']); }); Container::$routeCollection->group('oauth', function (RouteCollection $routeCollection) { - $routeCollection->get('oauth-auth', 'auth', [OAuthAuthController::class, 'auth']); - $routeCollection->post('oauth-token', 'token', [OAuthController::class, 'getToken']); - $routeCollection->get('oauth-userinfo', 'userinfo', [OAuthController::class, 'getUserInfo']); - $routeCollection->get('oauth-config', '.well-known/openid-configuration', [OAuthController::class, 'getConfig']); - $routeCollection->get('oauth-certs', 'certs', [OAuthController::class, 'getCerts']); + $routeCollection->get('oauth.auth', 'auth', [OAuthAuthController::class, 'auth']); + $routeCollection->post('oauth.token', 'token', [OAuthController::class, 'getToken']); + $routeCollection->get('oauth.userinfo', 'userinfo', [OAuthController::class, 'getUserInfo']); + $routeCollection->get('oauth.config', '.well-known/openid-configuration', [OAuthController::class, 'getConfig']); + $routeCollection->get('oauth.certs', 'certs', [OAuthController::class, 'getCerts']); }); Container::$routeCollection->group('password', function (RouteCollection $routeCollection) { - $routeCollection->get('password-requestReset', 'requestReset', [LoginController::class, 'getRequestPasswordResetForm']); - $routeCollection->post('password-requestReset-action', 'requestReset', [LoginController::class, 'requestPasswordReset']); - $routeCollection->get('password-requestReset.success', 'requestReset/success', [LoginController::class, 'getRequestPasswordResetSuccess']); - $routeCollection->get('password-reset', 'reset/{token}', [LoginController::class, 'getResetPasswordForm']); - $routeCollection->post('password-reset.action', 'reset/{token}', [LoginController::class, 'resetPassword']); + $routeCollection->get('password.requestReset', 'requestReset', [LoginController::class, 'getRequestPasswordResetForm']); + $routeCollection->post('password.requestReset-action', 'requestReset', [LoginController::class, 'requestPasswordReset']); + $routeCollection->get('password.requestReset.success', 'requestReset/success', [LoginController::class, 'getRequestPasswordResetSuccess']); + $routeCollection->get('password.reset', 'reset/{token}', [LoginController::class, 'getResetPasswordForm']); + $routeCollection->post('password.reset-action', 'reset/{token}', [LoginController::class, 'resetPassword']); }); Container::$routeCollection->get('logout', 'logout', [LoginController::class, 'logout']); Container::$routeCollection->group('account', function (RouteCollection $routeCollection) { @@ -57,26 +56,26 @@ Container::$routeCollection->group('account', function (RouteCollection $routeCo }); Container::$routeCollection->get('searchUser', 'searchUser', [UserSearchController::class, 'searchUser']); Container::$routeCollection->group('communities', function (RouteCollection $routeCollection) { - $routeCollection->get('community-new', 'new', [CommunityController::class, 'getCommunityNew']); - $routeCollection->post('community-new-action', 'new', [CommunityController::class, 'saveCommunity']); + $routeCollection->get('community.new', 'new', [CommunityController::class, 'getCommunityNew']); + $routeCollection->post('community.new-action', 'new', [CommunityController::class, 'saveCommunity']); $routeCollection->group('{communityId}', function (RouteCollection $routeCollection) { $routeCollection->get('community', '', [CommunityController::class, 'getCommunityHome']); $routeCollection->get('community.settings', 'settings', [CommunityController::class, 'getCommunitySettings']); - $routeCollection->get('community-edit', 'edit', [CommunityController::class, 'getCommunityEdit']); - $routeCollection->post('community-edit-action', 'edit', [CommunityController::class, 'saveCommunity']); - $routeCollection->get('community-members', 'members', [CommunityController::class, 'getMembersEdit']); - $routeCollection->post('community-members-new', 'newMember', [CommunityController::class, 'saveMember']); - $routeCollection->post('community-members-edit', 'editMember', [CommunityController::class, 'saveMember']); - $routeCollection->post('community-members-delete', 'deleteMember', [CommunityController::class, 'deleteMember']); - $routeCollection->get('community-currencies', 'currencies', [CommunityController::class, 'getCurrenciesEdit']); - $routeCollection->post('community-currencies-new', 'newCurrency', [CommunityController::class, 'saveCurrency']); - $routeCollection->post('community-currencies-edit', 'editCurrency', [CommunityController::class, 'saveCurrency']); - $routeCollection->post('community-currencies-delete', 'deleteCurrency', [CommunityController::class, 'deleteCurrency']); + $routeCollection->get('community.edit', 'edit', [CommunityController::class, 'getCommunityEdit']); + $routeCollection->post('community.edit-action', 'edit', [CommunityController::class, 'saveCommunity']); + $routeCollection->get('community.members', 'members', [CommunityController::class, 'getMembersEdit']); + $routeCollection->post('community.members.new-action', 'members/new', [CommunityController::class, 'saveMember']); + $routeCollection->post('community.members.edit-action', 'members/edit', [CommunityController::class, 'saveMember']); + $routeCollection->post('community.members.delete-action', 'members/delete', [CommunityController::class, 'deleteMember']); + $routeCollection->get('community.currencies', 'currencies', [CommunityController::class, 'getCurrenciesEdit']); + $routeCollection->post('community.currencies.new-action', 'currencies/new', [CommunityController::class, 'saveCurrency']); + $routeCollection->post('community.currencies.edit-action', 'currencies/edit', [CommunityController::class, 'saveCurrency']); + $routeCollection->post('community.currencies.delete-action', 'currencies/delete', [CommunityController::class, 'deleteCurrency']); $routeCollection->group('currencyExchangeRates', function (RouteCollection $routeCollection) { - $routeCollection->get('community-currency-exchange-rates', '{code}', [CommunityController::class, 'getCurrencyExchangeRates']); - $routeCollection->post('community-currency-exchange-rates-new', '{code}/new', [CommunityController::class, 'saveCurrencyExchangeRate']); - $routeCollection->post('community-currency-exchange-rates-edit', '{code}/edit', [CommunityController::class, 'saveCurrencyExchangeRate']); - $routeCollection->post('community-currency-exchange-rates-delete', '{code}/delete', [CommunityController::class, 'deleteCurrencyExchangeRate']); + $routeCollection->get('community.currencyExchangeRates', '{code}', [CommunityController::class, 'getCurrencyExchangeRates']); + $routeCollection->post('community.currencyExchangeRates.new-action', '{code}/new', [CommunityController::class, 'saveCurrencyExchangeRate']); + $routeCollection->post('community.currencyExchangeRates.edit-action', '{code}/edit', [CommunityController::class, 'saveCurrencyExchangeRate']); + $routeCollection->post('community.currencyExchangeRates.delete-action', '{code}/delete', [CommunityController::class, 'deleteCurrencyExchangeRate']); }); $routeCollection->group('transactions', function (RouteCollection $routeCollection) { $routeCollection->get('community.transactions', '', [TransactionController::class, 'getTransactions']); @@ -84,7 +83,7 @@ Container::$routeCollection->group('communities', function (RouteCollection $rou $routeCollection->post('community.transactions.new-action', 'new', [TransactionController::class, 'saveTransaction']); $routeCollection->get('community.transactions.edit', '{transactionId}', [TransactionController::class, 'getTransactionEdit']); $routeCollection->post('community.transactions.edit-action', '{transactionId}', [TransactionController::class, 'saveTransaction']); - $routeCollection->post('community.transactions.delete', '{transactionId}/delete', [TransactionController::class, 'deleteTransaction']); + $routeCollection->post('community.transactions.delete-action', '{transactionId}/delete', [TransactionController::class, 'deleteTransaction']); }); }); });