Allow users to change name on profile page#3357
Open
rhysyngsun wants to merge 7 commits into
Open
Conversation
b2b4263 to
e1918ab
Compare
OpenAPI Changes35 changes: 19 error, 0 warning, 16 info Unexpected changes? Ensure your branch is up-to-date with |
1eff7d2 to
3526158
Compare
3526158 to
06da37b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What are the relevant tickets?
Fixes https://github.com/mitodl/hq/issues/11260
Description (What does it do?)
This makes the name input on the profile edit page functional. It does so by optimistically updating the value in the DB and then writing the new value upstream to Keycloak. As part of this, I've also modified the apisix middleware to not update existing users because this ends up overwriting on the new value immediately because apisix has a stale view of the userinfo. This means we depend on SCIM for updates, so if you don't have that configured locally you won't see updates happen for learn anymore.
Some changes related to making this happen:
WritableSerializerMethodFieldso that the implementation is more correct. The reason for this is becauseField.__init__()dynamically sets some properties based onread_only=True, whichSerializerMethodFieldis hardcoded with. So I use Python's method resolution order (MRO) to strip that out betweenSerializerMethodField.__init__()andField.__init__(). This results in more technically correct internal state of the field. However, it also had the side effect of making a bunch of fields required (aforemetioned dynamic behavior). To avoid this, I set default values in some places where it made sense, but left some as required (specifically the widget config) because that makes sense.How can this be tested?
Go to the profile page and update your name. It should save successfully and your name on the dashboard and header should update. If you perform a full page update you should still see the new user value. You should also check keycloak to verify the new value is there as well.
The SCIM integration already works so no need to test that.