i try to redirect a client to a specific url, after he has logged in. In the cookbook, i find the solution, how to redirect a logged in user to home ("/"), but when i send my client a link to an unlisted page, which is password protected, i want him to redirect to this specific page.
In a multilang environment, you would have to pass the language code in the URL before login. Do you use the language code for all languages including the default language?
Well, it would be helpful to know what the debugger wants to tell us .
âDo you use the language code for all languages including the default language?â
Do you mean, that in every url is the language embedded? Like âhttp://âŚ/de/âŚâ Yes, it is. I use english and german, and every url is with a â/de/â or â/en/â.
I have to try it in a clean Kirby-installation. On my Testsite now, this solution ends again with the debugger.
I think, i understood the way it should work, but maybe i have a mistake, anywhere in my code, or in the routes (?! i dont know). i have to find it first.
Thank you so much!!
I will report, if i find the way, how this could work.
Hi @Adrieng, are you on Kirby 3.6.2 already? There was an issue (related PR and discussion here) that caused this kind of behaviour when redirecting to non-panel URLs up to 3.6.1.
Indeed Iâm using Kirby 3.6.2. The fix is still on a development branch (Iâm not very used to git / github workflows) ? No way to do it for the moment ?
@Adrieng Hmm. That particular fix got merged into main before the release of 3.6.2, and was already released in that latest stable version. So there has to be another reason for your problem â sorry that wasnât the solution!
I hope somebody else can point you in the right directionâŚ
One more thought on this: would using the home option of the user blueprint be an alternative for your use case instead of employing a hook? (I somehow have a hunch this issue might have to do with the hook.)
The home option is the âofficialâ way to do such redirects after login, and that one works in 3.6.2 as I have tested myself âŚanecdotally, thatâs how we initially discovered that bug I referred to earlier.
Interesting.
The problem is that I want to redirect to a variable url. I guess this way itâs not possible to get a data from the localStorage, isnât it ?
That should be possible by using a custom site method. We had a discussion around such a use case a little while ago, maybe that can serve as an inspiration:
In a nutshell: You can set the home option to call a custom site method (e.g. home: "{{ site.logintarget }}"), where the site method logintarget should return the desired URL. In my solution for that specific scenario, I store the variable URL in the Kirby session, but you could of course use any other source for that URL to be returned.