Skip to content

add display_name field to users and use user_id as unique identifier#1722

Merged
elfkuzco merged 1 commit intomainfrom
user-displayname
Mar 2, 2026
Merged

add display_name field to users and use user_id as unique identifier#1722
elfkuzco merged 1 commit intomainfrom
user-displayname

Conversation

@elfkuzco
Copy link
Collaborator

Rationale

This PR refactors the API/UI to use both the username and id to perform actions on user views. Since Ory integration, users can have names which are similar to existing users (registered locally) and this would result in a unique constraint violation. To mitigate this, a new column display_name is added to the DB and API responses. This field is not unique and serves as a place to store the names coming from Ory and the locally registered users. For local users, the display name is generally the same as the username.

Changes

  • add display_name field to dB and API responses
  • allow path parameters to take in either user_id or username (since both are unique)
  • refactor UI calls to make requests with user_id instead of username
  • refactor logic that prevents unprivileged users from modifying other users into a reusable dependency

This closes #1689

@elfkuzco elfkuzco self-assigned this Feb 26, 2026
@elfkuzco
Copy link
Collaborator Author

Pending elaboration on #1689 (comment), this seems to align with much of #1689

@elfkuzco elfkuzco requested a review from benoit74 February 26, 2026 15:37
@elfkuzco elfkuzco force-pushed the drop-user-email-column branch from d11d369 to 1674d40 Compare February 26, 2026 15:47
@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

❌ Patch coverage is 85.33333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.55%. Comparing base (5278c9a) to head (f1a783d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...kend/src/zimfarm_backend/api/routes/users/logic.py 69.56% 3 Missing and 4 partials ⚠️
...end/src/zimfarm_backend/api/routes/dependencies.py 78.57% 2 Missing and 1 partial ⚠️
backend/src/zimfarm_backend/utils/scheduling.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1722      +/-   ##
==========================================
+ Coverage   83.35%   83.55%   +0.19%     
==========================================
  Files          97       97              
  Lines        4837     4853      +16     
  Branches      500      496       -4     
==========================================
+ Hits         4032     4055      +23     
+ Misses        671      667       -4     
+ Partials      134      131       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Base automatically changed from drop-user-email-column to main February 26, 2026 15:53
@elfkuzco elfkuzco linked an issue Feb 27, 2026 that may be closed by this pull request
@benoit74 benoit74 removed their request for review March 2, 2026 08:46
@elfkuzco elfkuzco requested review from benoit74 and removed request for benoit74 March 2, 2026 11:21
Copy link
Collaborator

@benoit74 benoit74 left a comment

Choose a reason for hiding this comment

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

LGTM, one minor fix and you can merge.

I'm not satisfied anymore at all by the user screens, but let's move this topic to a distinct issue, this PR already achieves what we need to be able to handle (way beyond what was originally foreseen in the issue description), and UI rearrangement is more a detail.

Before merging, can you double check we will not break any "running" thing due to API change (besides the frontend which will have to be updated as soon as API is updated of course, I'm more thinking about workers and tasks). I don't think so, but I prefer to ask ^^

@elfkuzco
Copy link
Collaborator Author

elfkuzco commented Mar 2, 2026

Before merging, can you double check we will not break any "running" thing due to API change (besides the frontend which will have to be updated as soon as API is updated of course, I'm more thinking about workers and tasks). I don't think so, but I prefer to ask ^

Yup. Nothing should break. There's no logic to change token decoding or key authentication with SSH (so long as workers have username since that's used in generating the auth message). Tested locally with a new task and everything works fine.

@elfkuzco elfkuzco merged commit 40871a0 into main Mar 2, 2026
7 checks passed
@elfkuzco elfkuzco deleted the user-displayname branch March 2, 2026 14:12
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.

Clean usage of username and displayname

2 participants