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

Redirect to last page after login #788

Closed
moshfeu opened this issue Jun 3, 2021 · 12 comments
Closed

Redirect to last page after login #788

moshfeu opened this issue Jun 3, 2021 · 12 comments
Assignees
Labels
enhancement New feature or request level: player Medium level task - Usually require small code design / exploring tools skills

Comments

@moshfeu
Copy link
Member

moshfeu commented Jun 3, 2021

Currently if a user try to access back office while they are not logged in, they redirected to the home page.

The expected result:

Redirect to login and remember the page they redirected from. After successful login, they should be redirected to this page

@moshfeu moshfeu added enhancement New feature or request help wanted Extra attention is needed labels Jun 4, 2021
@nikhils4
Copy link

nikhils4 commented Jun 9, 2021

Hi @moshfeu,

I am not sure if this approach would be feasible or not, but once we get the Unauthorised response from the server, before redirecting can't we store the URL of the current page in Local Storage and once the user has successfully logged in, we can check for the existence of that particular value in Local Storage if that's available we can redirect the user to that page else we can redirect to the home page.

Let me know your thoughts on this.

@moshfeu
Copy link
Member Author

moshfeu commented Jun 10, 2021

Hi @nikhils4!
I believe it can be done that way but it might cause issues. For instance, if the user closes the browser before the login completed and they redirected back to our site. This way, next time the user comes to the website, we have the local storage value and we'll try to redirect them to the back office.

I'd suggest to use the state param of auth0. We're already using it, take a look the auth module:

appState: {
origin: isMentorIntent ? 'mentor' : 'user',
},

@moshfeu moshfeu added the level: player Medium level task - Usually require small code design / exploring tools skills label Jun 16, 2021
@moshfeu
Copy link
Member Author

moshfeu commented Jun 29, 2021

@nikhils4 do you want to take this?

@nikhils4
Copy link

Sorry for not getting back on this, had a crazy last week and would remain unavailable until next week, later I can pick this up, if that's okay.

@moshfeu
Copy link
Member Author

moshfeu commented Jun 29, 2021

No worries!
I'll keep it "help needed". If someone could take it before, you could pick another one.
Thanks!

@nikhils4
Copy link

Thanks a lot, for sure once available will pick this up :)

@migtomace
Copy link
Contributor

Hi, I have forked the repo and have it running. I would like to work on this issue but would like clarification on the "back office". Is this a space for mentors?

@migtomace
Copy link
Contributor

Actually, I see the issue.

@moshfeu
Copy link
Member Author

moshfeu commented Jul 15, 2021

Great :) Thank you

@migtomace
Copy link
Contributor

@moshfeu Where is isMentorIntent being inputed into the login function? It's not called in the LoginNavigation. I would like to add a from parameter as well, but I'm not sure I can do that without messing up other code.

login = isMentorIntent => {
this.auth0.authorize({
appState: {
origin: isMentorIntent ? 'mentor' : 'user',
},
redirectUri: window.location.href
});
};

@migtomace
Copy link
Contributor

Nevermind, I figured it out finally. Now I am dealing with the same issue logging out of the backend. It needs to be sent to the front end to logout or else it just keep logging back in.

@moshfeu
Copy link
Member Author

moshfeu commented Aug 29, 2021

Done by #830 👏

@moshfeu moshfeu closed this as completed Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request level: player Medium level task - Usually require small code design / exploring tools skills
Projects
None yet
Development

No branches or pull requests

3 participants