flipboxfactory / saml-sp

SAML Service Provider (SP) Plugin for Craft CMS
https://saml-sp.flipboxfactory.com/
Other
19 stars 5 forks source link

RelayState Variable Scenario - Does not redirect back to the given URL #16

Closed jeffsikes closed 6 years ago

jeffsikes commented 6 years ago

This may be a "working as intended" item, but there is a scenario where the RelayState variable does not return you to the expected page.

Scenario:

dsmrt commented 6 years ago

After a bit of investigation, I found this really difficult to fix from my side and am going to suggest you handle it on yours.

Why this happens Craft takes over before I can do much about this due to us using the the loginPath general configuration. Since we are using that Craft sees that you are already login and doesn't want to take you back there, to the login page.

How to handle this Correct me if I'm wrong but I was thinking you could do something like this:

{% if currentUser %}
     <a href="{{ destination }}">Destination</a>
{% else %}
     <a href="{{ myLoginPath }}?RelayState={{ destination }}">Destination</a>
{% endif %}