-
Notifications
You must be signed in to change notification settings - Fork 8
Feature/redirect after login #178
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
base: feature/ewi
Are you sure you want to change the base?
Conversation
Refactor the redirect handling logic so that we can debug it. By moving some parts to a central place and re-use some logic, we can determine that the Login router was re-setting the $redirectPath to "/login" on hitting the login page. We've now fixed this. And on return are redirected to the page that we got the access denied on. remaining issue: If a user hits a path only accessible to **students**, logs in with a **staff** role, the redirect will land them on a page that they have no access to, which then triggers the login logic. Same with staff path and login as user. This can, and most likely will, put the user in an endless redirect loop! This issue existed in the previous logic. But might not have surfaced because the redirects didn't work properly. The chances of this triggering is small though: it will only exist with users that both have a backpack as student and a staff account as staff, and then only when they mix up logins.
Made url parameter handling consistent. Named methods for easier reading.
By forcefully setting the role and link
This removes previously introduced url arguments. but introduces a duplication of what routes are available to current role.
|
@Iso5786 Can you also answer the following?
|
|
@Iso5786 Once we have the strategy in place, I'll make this also a PR against develop. I'll have to backport some minor changes, so I'll rather do them once only, here. And then present the result for "develop". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
This is an attempt to allow for dropping the user into the login flow automatlically.
The strategy taken is to build on top of what exists, changing as little as possible. This has severe downsides, and some upsides.
This PR explores two alternative solutions:
url arguments on login
Up to commit 49d6b56
/login?redirectPath=%2Fdetails%2Fq5Of2C1RSX-s3DBCmvvwGg%3Ffoo%3Dbar&role=student.
We can present this url in Emails and other channels.
magic determiniation of role based on the path wanted to visit.
Commit a0a485d replaces previous alternative with this alternative.
When visiting a page that we don't have access to, we look up the requested path in a table that maps the path to the required role.
We can now send the user into the login flow for this role with force=true, forcing a re-login.
Generic pros and cons over a Component Based (see below) Alternative:
Alternative strategy:
I have researched some alternatives to above. These could be considered "The Proper Svelte Way" or such. From this, below strategy is IMO cleanest and simplest.
<AuthenticationProvider>component wrapping the<Router>- This would check that there is a) a user and that this user has b) a role - basic authentication.<ProtectedRoutes requiredRole={{role.STUDENT}}>component that mounts underlying routes only if requiredRole == currentRole - basic authorization.I've weighed pros and cons and decided that such a large change is not a good option to fix a seemingly small feature.