Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the login flow to support authentication with either a username or an email address, replacing the previous username-only login. A new get_user_by_identifier service function performs an OR-based lookup, the LoginRequest schema is updated to accept either field, and the client UI and generated API types are updated accordingly.
Changes:
- New
LoginRequestschema accepts eitherusernameoremail(with a model-validator enforcing at least one) and exposes a computedidentifierproperty - New
get_user_by_identifierDB query replacesget_user_by_usernamein the authentication path;authenticate_userandloginservice signatures renamedusername→identifier - Client
Login.tsxunified the form input into a single "Username or Email" field; generated TypeScript types and Zod schemas updated to match
Reviewed changes
Copilot reviewed 13 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
server/app/models/schemas/types.py |
Introduces shared Pydantic type aliases (Name, Username, Password, Token, Email) |
server/app/models/schemas/auth.py |
Updates LoginRequest to accept username | None and email | None with cross-field validator and identifier property |
server/app/services/user.py |
Adds get_user_by_identifier using or_() on username and email columns |
server/app/core/security.py |
authenticate_user now takes identifier and delegates to get_user_by_identifier |
server/app/services/auth.py |
login signature uses identifier instead of username |
server/app/api/endpoints/auth.py |
Passes req.identifier to the login service |
client/src/pages/Login.tsx |
Replaces username-only input with combined identifier input; builds correct API payload in onSubmit |
client/src/api/generated/types.gen.ts |
LoginRequest type now has optional username and new optional email |
client/src/api/generated/zod.gen.ts |
zLoginRequest schema updated to make username nullish, add email nullish field |
client/src/api/generated/schemas.gen.ts |
OpenAPI schema updated: username optional, email added, only password required |
server/app/tests/services/user/test_get_user_by_identifier.py |
New tests for get_user_by_identifier |
server/app/tests/services/auth/test_login.py |
Adds email login test, renames username to identifier |
server/app/tests/models/schemas/test_auth.py |
New unit tests for LoginRequest validator |
server/app/tests/core/security/test_authenticate_user.py |
Adds email authentication test, renames param |
server/app/tests/api/utilities.py |
login helper extended to optionally accept email |
server/app/tests/api/auth/test_login.py |
New email login and missing-identifier tests replace old invalid-body test |
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.
No description provided.