flow: Router throws exception when navigating between PermitAll and AnonymousAllowed views
Description of the bug
I have two views one is anonymous allowed, the other one requires login. When I try to navigate from anonymous to another one, a console errors are logged
https://github.com/user-attachments/assets/c9135106-e639-465b-8dff-15f909cf3bf3
.
Expected behavior
There should not be any console errors.
Minimal reproducible example
Create two views as below. Activate Copilot and click the links in Views & Routes panel
LoggedInOnly.java
@Route(value = "loggedin")
@PermitAll
public class LoggedInOnly extends VerticalLayout {
public LoggedInOnly(AuthenticatedUser authenticatedUser) {
}
}
LoginView.java
@AnonymousAllowed
@PageTitle("Login")
@Route(value = "login")
public class LoginView extends LoginOverlay implements BeforeEnterObserver {
private final AuthenticatedUser authenticatedUser;
public LoginView(AuthenticatedUser authenticatedUser) {
this.authenticatedUser = authenticatedUser;
setAction(RouteUtil.getRoutePath(VaadinService.getCurrent().getContext(), getClass()));
}
@Override
public void beforeEnter(BeforeEnterEvent event) {
if (authenticatedUser.get().isPresent()) {
// Already logged in
setOpened(false);
event.forwardTo("");
}
setError(event.getLocation().getQueryParameters().getParameters().containsKey("error"));
}
}
Versions
Hilla: 24.7.0.alpha9 Flow: 24.7.0.alpha9 Vaadin: 24.7.0.alpha6 Spring Boot: 3.4.2 Spring: 6.2.2 Spring Security: Enabled Copilot: 24.7-SNAPSHOT Frontend Hotswap: Enabled, using Vite OS: aarch64 Mac OS X 14.7.1 Java: JetBrains s.r.o. 21.0.5 Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Java Hotswap: Java Hotswap is enabled IDE Plugin: 1.4.6 IntelliJ
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- fix: add global click handler for navigation When using React router, clicks on anchors are intercepted only if Flow client has been initialized. In Hilla or hybrid application, if a Flow view is nev... — committed to vaadin/flow by mcollovati 2 years ago
- fix: add global click handler for navigation When using React router, clicks on anchors are intercepted only if Flow client has been initialized. In Hilla or hybrid application, if a Flow view is nev... — committed to vaadin/flow by mcollovati 2 years ago
- fix: add global click handler for navigation (#20990) When using React router, clicks on anchors are intercepted only if Flow client has been initialized. In Hilla or hybrid application, if a Flow vi... — committed to vaadin/flow by mcollovati 2 years ago
- fix: add global click handler for navigation (#20990) When using React router, clicks on anchors are intercepted only if Flow client has been initialized. In Hilla or hybrid application, if a Flow vi... — committed to vaadin/flow by mcollovati 2 years ago
- fix: add global click handler for navigation (#20990) (#21147) When using React router, clicks on anchors are intercepted only if Flow client has been initialized. In Hilla or hybrid application, if ... — committed to vaadin/flow by vaadin-bot 2 years ago
- fix: add global click handler for navigation (#20990) (#21148) When using React router, clicks on anchors are intercepted only if Flow client has been initialized. In Hilla or hybrid application, if ... — committed to vaadin/flow by vaadin-bot 2 years ago
- fix: add global click handler for navigation (#20990) When using React router, clicks on anchors are intercepted only if Flow client has been initialized. In Hilla or hybrid application, if a Flow vi... — committed to vaadin/flow by mcollovati 2 years ago
From Copilot point of view it is irrelevant as Vaadin router is not supported
Would https://github.com/vaadin/flow/blob/main/flow-server/src/main/resources/com/vaadin/flow/server/frontend/vaadin-react.tsx be the correct place?