- Issue created by @g_miric
- 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU
This is a variation on an "Occasionally asked question" in the README:
Redirect from /original/path to /saml/login?destination=original/path
Note that "original destination" has no special meaning to the samlauth module.
The module sits on /saml/login, and with "original destination", I assume you mean the path that the user visited previously, before redirecting to /saml/login. This "original path" is equivalent to any other path you want to redirect to after logging in. Which you do with saml/login?destination=any/path - Status changed to Closed: works as designed
about 1 year ago 1:46pm 21 June 2023 Hello,
I have the same issue as g_miric, but not sure how they solved the issue given your response.
I've successfully used the login redirect url field to route users to a specific path after logging in, but I'm unsure how to make this dynamic and route to the page they were trying to visit.
For example:
1.user visits www.example.com/a
2. access restricted and presented with login
3. user successfully logs in and continues to www.example.com/aThanks for helping me understand!
- 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU
It's about your point 2
2. access restricted and presented with login
I am assuming something (outside of the samlauth module) is redirecting to /saml/login, for that purpose.
It should be redirecting to /saml/login?destination=a instead.
Thank you for wording that another way. This makes a lot more sense now!
In our case, we have a custom login block with the button pointed to /saml/login
My next task will be to figure out how to make the button dynamic based on the current page so the button points to
/saml/login?destination=a
Appreciate the help!
- 🇮🇳India suyash.vaidya Jaipur
@bellsworth, you can use the
hook_link_alter()
for adding the language code as destination query parameter:/** * Implements hook_link_alter(). */ function module_name_link_alter(array &$variables): void { // Add language code as destination query string to SAML login menu link for returning user to correct language when path prefix language detection is used. $url = $variables['url']->toString(); if ($url == '/saml/login') { $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); $variables['options']['query']['destination'] = $language; } }