From e888b8551f6e7f1025170a856194dfdeeb1573aa Mon Sep 17 00:00:00 2001 From: Macavity <300609+Macavity@users.noreply.github.com> Date: Sun, 18 Feb 2024 14:43:13 +0100 Subject: [PATCH 1/2] fix: pages protected by login and wrong encryption of users created through fixtures --- .../components/account/AccountBalance.tsx | 43 ++++++++++--------- config/packages/security.yaml | 3 ++ src/Controller/SecurityController.php | 2 +- src/Factory/UserFactory.php | 10 ----- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/assets/client/components/account/AccountBalance.tsx b/assets/client/components/account/AccountBalance.tsx index cb89615..a3ba49d 100644 --- a/assets/client/components/account/AccountBalance.tsx +++ b/assets/client/components/account/AccountBalance.tsx @@ -57,30 +57,33 @@ export default function AccountBalance() { backTo={`/accounts/${id}`} >
- {isLoading && } -
- {balance &&
{balance}
} + {isLoading ? ( + + ) : ( +
+ {balance &&
{balance}
} -
-
- funny image -
-
-
-
- {t('OVERVIEW.PAYDAY_WEEKDAY_LABEL')}  - - {nextPayday ?? t('OVERVIEW.PAYDAY_WEEKDAY_UNKNOWN')} - +
+
+ funny image +
-
- {t('OVERVIEW.PAYDAY_COUNTER_LABEL')}  - - {daysUntilNextPayday ?? t('OVERVIEW.PAYDAY_COUNTER_UNKNOWN')} - +
+
+ {t('OVERVIEW.PAYDAY_WEEKDAY_LABEL')}  + + {nextPayday ?? t('OVERVIEW.PAYDAY_WEEKDAY_UNKNOWN')} + +
+
+ {t('OVERVIEW.PAYDAY_COUNTER_LABEL')}  + + {daysUntilNextPayday ?? t('OVERVIEW.PAYDAY_COUNTER_UNKNOWN')} + +
-
+ )}
); diff --git a/config/packages/security.yaml b/config/packages/security.yaml index bbbd963..e2dcc58 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -35,6 +35,9 @@ security: # Note: Only the *first* access control that matches will be used access_control: - { path: ^/admin, roles: ROLE_ADMIN } + - { path: ^/accounts/, roles: ROLE_USER } + - { path: ^/user/, roles: ROLE_USER } + - { path: ^/dashboard, roles: ROLE_USER } # - { path: ^/profile, roles: ROLE_USER } when@test: diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index d8149f0..4808048 100644 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -52,7 +52,7 @@ public function login(AuthenticationUtils $authenticationUtils): Response 'csrf_token_intention' => 'authenticate', // the URL users are redirected to after the login (default: '/admin') - 'target_path' => '/accountselection', + 'target_path' => '/dashboard', // the label displayed for the username form field (the |trans filter is applied to it) 'username_label' => 'Your username', diff --git a/src/Factory/UserFactory.php b/src/Factory/UserFactory.php index f607308..4ce81d4 100644 --- a/src/Factory/UserFactory.php +++ b/src/Factory/UserFactory.php @@ -68,14 +68,4 @@ protected function getDefaults(): array ]; } - /** - * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization - */ - protected function initialize(): self - { - return $this - ->afterInstantiate(function (User $user) { - $user->setPassword($this->passwordHasher->hashPassword($user, $user->getPassword())); - }); - } } From 136482753d595f8f64b54b36162287f4e513eccf Mon Sep 17 00:00:00 2001 From: Macavity <300609+Macavity@users.noreply.github.com> Date: Sun, 18 Feb 2024 14:45:21 +0100 Subject: [PATCH 2/2] fix: add "go back" to parent dashboard until we have a better solution --- assets/client/components/account/AccountBalance.tsx | 3 ++- assets/client/components/account/AccountDashboard.tsx | 5 ++++- src/Factory/UserFactory.php | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/assets/client/components/account/AccountBalance.tsx b/assets/client/components/account/AccountBalance.tsx index a3ba49d..ea64f9a 100644 --- a/assets/client/components/account/AccountBalance.tsx +++ b/assets/client/components/account/AccountBalance.tsx @@ -13,6 +13,7 @@ import { getFormattedNextPayday, } from '@/client/utils/date'; import { Locale } from '@/client/interfaces/Locale'; +import { pathToRoute } from '@/client/utils/pathToRoute'; export default function AccountBalance() { const { t, i18n } = useTranslation(); @@ -54,7 +55,7 @@ export default function AccountBalance() { return (
{isLoading ? ( diff --git a/assets/client/components/account/AccountDashboard.tsx b/assets/client/components/account/AccountDashboard.tsx index a62dc4e..c86dde8 100644 --- a/assets/client/components/account/AccountDashboard.tsx +++ b/assets/client/components/account/AccountDashboard.tsx @@ -37,7 +37,10 @@ export default function AccountDashboard() { ]; return ( - +
{sections.map((section, index) => ( diff --git a/src/Factory/UserFactory.php b/src/Factory/UserFactory.php index 4ce81d4..fbc23a1 100644 --- a/src/Factory/UserFactory.php +++ b/src/Factory/UserFactory.php @@ -67,5 +67,4 @@ protected function getDefaults(): array 'roles' => [UserRole::USER], ]; } - }