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

Return User Info from Login Endpoint #136

Merged
merged 7 commits into from
Oct 14, 2022
Merged

Conversation

rajadain
Copy link
Contributor

@rajadain rajadain commented Oct 13, 2022

Overview

Returns user details from the login endpoint. Both when logging in a new user, and when fetching an already logged in user, we return details about the user, which include their email, Role, and list of Utilities.

Adds a Utility and State serializer along the way. Updates front-end redux arrangement to consume the new user object for login state management. Also uses the user's list of utilities to correctly render the Nav Bar.

Closes #123

Demo

image

Testing Instructions

Checklist

  • fixup! commits have been squashed
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines
  • README.md updated if necessary to reflect the changes
  • CI passes after rebase

@jacobtylerwalls
Copy link
Contributor

Taking a look now.

@rajadain
Copy link
Contributor Author

For some reason the linter integration with my VSCode isn't working, leading to all the linting errors. 9552480 should be the last fix that takes care of it.

@jacobtylerwalls
Copy link
Contributor

jacobtylerwalls commented Oct 13, 2022

One thing quickly, since I know you're online. With this PR we now lose the ability to keep the user logged in after refresh, i.e. when we lose redux state. I don't know if our usual approach is to persist the redux state, or to tolerate more API calls, or to just tolerate logging the user out.

@rajadain
Copy link
Contributor Author

Nice catch! Had missed saving the user state in PrivateRoute. Fixed in 33930fe

Copy link
Contributor

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Tested, works great!

src/django/api/serializers/state.py Outdated Show resolved Hide resolved
The State serializer is very minimal, fits its current purpose.
Other more detailed serializers may be added in the future.
When fetching an already logged in user, or logging in a new
user, always return the user's email, role, and utilities.
This will be used to inform the front-end about various
decisions.
Now that the API returns a user object with details, we store
the whole thing in Redux, and switch away from signedIn: true
as the signifier for login state.
Now that the login endpoint gives us the user's utilities,
we use those instead of the placeholders in the UI.

Also update the redux logic to match the back-end utility
data structure.
@rajadain rajadain merged commit bde5864 into develop Oct 14, 2022
@rajadain rajadain deleted the tt/get-user-info-from-login branch October 14, 2022 03:37
@rajadain
Copy link
Contributor Author

Thanks for reviewing!

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.

Return User Details from Login Endpoint
2 participants