Redirect to certain pages after login in multilanguage
I have an 8.2.1 site with more than one language.
The home pages are used to display general info for unauthenticated users. The localized home page is selected using the language switch block. Then user choose to login and the login page is displayed in the correct language.
What I need is to redirect users after login, to a certain page in the correspondent language tree, let's call this page: "protected-home".
All I could do is to send users to the default language /en/protected-home instead of the one in their correspondent language, like /ro/protected-home
Options I found/tried:
1. Used the "Login destination" options, to redirect to a custom page. This does not work because it asks you to specify a page under one language only. (Btw, this should be improved to take in account my situation)
2. I thought about adding a single page to use as a login destination (see above). But: new single pages cannot be created outside the language tree and, once it is inside a language tree, it is localized according to the language branch it is in. Also, 1 applies.
3. I tried to build a custom block based on "page redirect" add-on and it all worked ok as logic, but the block's view method is called much later than the page headers printing, so it was ignored.
4. I have tried a package instead of block, starting again from the "page redirect" add-on which is actually a package. Practically I have installed some language based redirection code in the "on_render" event listener, and I made the code active only for the /login. It failed by redirecting to the default (/en) because there is no "current language" info transported after the login. See next item.
5. I tried to fiddle with the login single page and its controller however it looks too complicated for my knowledge. What I (think I) am sure of, is that the login page gets the currently selected language as an input (hence it displays the localized field titles) but it does not transmit this info to the next step.
Any ideas on how to do it?
Thank you for taking your time to read this rather long explanation!