feat(admin-ui): Redirect to the right page on forbidden errors if an internal loginUrl
is provided
#2175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Goal
This PR closes #2136.
🧠 Approach
We are currently facing an issue with the AdminUI.
Indeed, we configure a
loginUrl
towards a custom page which is internal (it shares the same origin as the rest of the AdminUI pages).Therefore, when admins click on a link and face a
FORBIDDEN
error, they used to be totally redirected towards thisloginUrl
with awindow.location.href = loginUrl
, without the?redirectTo
query parameter.In this PR, I made sure to check if the
loginUrl
is on the same origin than the AdminUI (window.location.origin
). If that is the case, we redirect to that internalloginUrl
and provide the?redirectTo
query parameter.🧪 Test
vendure-ui-config.json
file, add the following to define a customloginUrl
:cd packages/dev-server yarn start
cd packages/admin-ui yarn start
http://localhost:4200/admin/login