Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard): Redirect to previous URL after login #469

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

RubenLWF
Copy link
Contributor

@RubenLWF RubenLWF commented Dec 9, 2024

Description

This PR ensures that if a user clicks on a link to a specific URL but needs to log in first, they will be redirected to the original URL after successfully logging in.

This is achieved by adding the page from the original link to the session storage before the user is redirected to the login page.
Then, after the user has logged in, the user will be redirected to the page in the session storage, or the home page if this is empty. After this it will be removed from session storage again.

I have decided to put this info in the session storage instead of in a query parameter as suggested in the example from the issue. This because using it as a query parameter will not work for the "Login via GEWIS" button since this button redirects the user, losing the query parameters in the URL.

I have not been able to test this with the "Login via GEWIS" button since this logs me in on sudosos.test.gewis.nl instead.

Related issues/external references

#452

Types of changes

  • New feature (non-breaking change which adds functionality)

@RubenLWF
Copy link
Contributor Author

Hi @SuperVK,
I am still not completely sure how the routing functions. Do you know which case in index.ts is entered after the login through the GEWIS site?

@SuperVK
Copy link
Member

SuperVK commented Dec 10, 2024

From the GEWIS website its gets back to a url with a token inside, then

authStore.gewisWebLogin(crypto.randomUUID(), token, apiService)
and
authStore.gewisWebLogin(crypto.randomUUID(), token, apiService).catch(() => {
make sure this token is traded in for an proper JWT token from SudoSOS. The first time you land on the auth you are not authenticated yet, so you land in the first if statement.

@RubenLWF RubenLWF requested a review from SuperVK December 10, 2024 17:00
@RubenLWF
Copy link
Contributor Author

Great, thanks!

In that case I believe this should do the trick 🙂

Copy link
Contributor

@JustSamuel JustSamuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@JustSamuel JustSamuel linked an issue Dec 10, 2024 that may be closed by this pull request
@JustSamuel JustSamuel merged commit fee9226 into develop Dec 10, 2024
2 checks passed
@JustSamuel JustSamuel deleted the feature/redirect-url-after-login branch December 10, 2024 20:03
@SuperVK SuperVK mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Redirect url after login
3 participants