-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
Router issue with multiple routes for the same page with different conditions #549
Comments
Just having a quick look here but it seems to me that if you remove the second definition of val loggedInRoutes = emptyRule |
staticRoute("/", Page.Dashboard) ~> render(Dashboard())
val routes = emptyRule |
staticRoute("/login", Page.Login) ~> render(Login()) |
loggedInRoutes.addCondition(_ => CallbackTo { Authentication.isLoggedIn })(_ =>
redirectToPage(Page.Login)(Redirect.Push))
routes.notFound(redirectToPage(Page.Dashboard)(Redirect.Replace)).renderWith(layout) |
Hmm, yeah, seems like it, I'll check this out. |
To be honest, I think that might be undefined behaviour. I don't remember.
But I definitely think that if it doesn't fail early saying "hey multiple
definitions of the same route aren't supported" then it should work as your
expecting.
…On Thu., 16 May 2019, 11:14 pm Akos Vandra, ***@***.***> wrote:
Hmm, yeah, seems like it, I'll check this out.
But in general having this kind of setup is not supported? (I mean having
the same route with multiple actions based on some mutually exclusive
conditions that cover the whole probability space?).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#549?email_source=notifications&email_token=AABRRN42JM7RUGXB7THSBDDPVVM27A5CNFSM4HNC6J3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVRYSKI#issuecomment-493062441>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABRRN5DOLXWSKZLFRS2KPDPVVM27ANCNFSM4HNC6J3A>
.
|
By failing early what do you mean? compile time, or runtime? The runtime exception that occurs, doesn't really satisfy the early failing though, so I guess this is either a bug that needs fixed / feature that has to be added, or a better error message added. |
Hey, FYI, for personal reasons I'm not finding myself with much time to spend on OSS lately. I hope that will get a bit better soon but I do get time I've already got a lot of other stuff to do (esp. Scala 2.13 upgrades) so I don't see myself being able to prioritise this issue for a long while. I do try to give PRs higher priority (esp when they're complete) so that's probably your best bet at helping get this resolved anytime soon. |
Gotcha! |
Closed via #616 |
This currenty throws a
RuntimeException(Unspecified action for page Dashboard at Path(/))
if the user is logged in:What I would like to achieve is the user to be redirected to the /login page if he tries to access a protected route without being logged in, and to be redirected to / if he tries to access a non-existent one. Since / is also a protected route currently, it should redirect to /login if the user is not authenticated.
Seems like the system gets confused by having to rules for the same Page with different conditions, which are mutually exclusive, so one of them should ALWAYS trigger. This shouldn't be a routing error.
The text was updated successfully, but these errors were encountered: