-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UX] Allow to redirect logged-in user on any routes and add a redirection for registration page #15418
base: 1.14
Are you sure you want to change the base?
[UX] Allow to redirect logged-in user on any routes and add a redirection for registration page #15418
Conversation
Bunnyshell Preview Environment deployment failedCheck https://github.com/Sylius/Sylius/actions/runs/7862012607 for details. Available commands:
|
@Jibbarth I test a different approach here because I use a different security config than the one present in security:
firewalls:
shop:
form_login:
default_target_path: sylius_shop_account_dashboard In the case I'm a registered customer and I register a second one I'm redirected to the dashboard. One drawback I saw : if your channel is configured to required the account verification then after the registration you are not logged in as the new customer. |
@Prometee 🤔 I'm not sure to follow you. The snippet you provide is for redirecting after login, right ? Here, we'll make a redirection for an already logged-in user that try to reach There is already such things for But maybe I missed something 😅 |
😱 oh no, my behat test seems no valid. Any clue to fix this? |
@Jibbarth nevermind I though you wanted to allow redirecting to the dashboard when already logged in. I didn't understand that you wanted to avoid this behaviour, sorry for that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice to have this ability to define a
logged_in_route
to redirect on every route. WDYT ?
Sounds nice, though I didn't work with html shop for years and don't have an opinion.
src/Sylius/Bundle/ShopBundle/EventListener/AlreadyLoggedInUserRegistrationListener.php
Outdated
Show resolved
Hide resolved
777684f
to
74f1b64
Compare
src/Sylius/Bundle/ShopBundle/EventListener/AlreadyLoggedInUserRegistrationListener.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/EventListener/AlreadyLoggedInUserRegistrationListener.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/EventListener/AlreadyLoggedInUserRegistrationListener.php
Outdated
Show resolved
Hide resolved
features/account/customer_account/redirect_when_already_signed_in.feature
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
src/Sylius/Bundle/ShopBundle/EventListener/AlreadyLoggedInUserRegistrationListener.php
Outdated
Show resolved
Hide resolved
features/account/customer_account/redirect_when_already_signed_in.feature
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/EventListener/AlreadyLoggedInUserRegistrationListener.php
Outdated
Show resolved
Hide resolved
Sorry @Rafikooo, i didn't see your comments. I'll try to address them as soon as possible 😉 |
Co-authored-by: Dmitri Perunov <diimpp@gmail.com>
d446e17
to
b6f21d7
Compare
Comments addressed @Rafikooo 😉 To handle both Login and registration behavior in the Listener, I moved it in UiBundle, cause the SecurityController act also for admin login. Moreover, the event is now more flexible. We can add a Two way to add the attribute : any_route:
# ...
defaults:
_sylius:
logged_in_route: sylius_shop_account_dashboard any_route:
# ...
defaults:
_sylius:
logged_in_route:
name: sylius_shop_account_dashboard
parameters:
param1: value1 |
// case logged_in_route: | ||
// name: 'app_route' | ||
// parameters: | ||
// param1: 'value1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tell me if such comment are not needed
@@ -40,6 +41,7 @@ public function __construct( | |||
private LoginPageInterface $loginPage, | |||
private NotificationCheckerInterface $notificationChecker, | |||
private SharedStorageInterface $sharedStorage, | |||
private RegisterPageInterface $registerPage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tell me if we should gather PageInterface together in order's declaration
Happy birthday little PR 🥳 @Rafikooo, is there anything else I can do here ? |
When a logged-in user visit registration page, he is now redirected directly to account dashboard page, like for /login.
I targetted the
sylius.customer.initialize_register
dispatched by the resource controller to not use a Request event that will be triggered on every page.However, while coding, as I added the
logged_in_route
in register route configuration, I was wondering if it wouldn't be better to add a generic event that check every route for thelogged_in_route
attribute, and in such case, we can perform the redirection.I think it would be nice to have this ability to define a logged_in_route to redirect on every route. WDYT ?
EDIT
We can now add a
logged_in_route
in any route, and the redirection will occur as soon as we are logged_in.Two way to add the attribute :