Registry Mirror
Skip to content

Conversation

@grandnode-dev

Copy link
Copy Markdown
Member

Type: bugfix

Issue

Admin → System → API users: adding a user with the e-mail of an existing API user, or changing a user's e-mail to one, answered 500. The UserApi.Email index is unique and the validators only checked that a customer with that e-mail exists. The e-mail was also stored as typed, while GetUserByEmail (used by the token endpoint and the JWT check) compares with a lower-case address, so an API user created with capitals could not get a token.

Solution

  • UserApiCreateValidator and UserApiValidator refuse an e-mail that another API user has ("An API user with this e-mail already exists"); editing a user keeps its own e-mail.
  • UserApiService stores the e-mail in lower case on insert and update, as GetUserByEmail looks it up, so the check and the index agree.

New resource Admin.System.UserApi.Email.Registered, in DefaultLanguage.xml and Upgrade/en_250.xml.

Breaking changes

None. Existing records keep the e-mail they have until they are saved again; a mixed-case record that already exists can still collide with the same address typed identically.

Testing

  1. Add an API user for an existing customer, then add a second one with the same e-mail: the grid shows the "already exists" message instead of a 500.
  2. Edit the first user without changing the e-mail: saves.
  3. Add a user typed as Api@Shop.com: stored as api@shop.com, and POST /api/token/create with that e-mail returns a token.

Tests: UserApiValidatorTests, UserApiServiceTests (lower case on insert and update).

Adding an API user, or changing one's e-mail, to an address another API
user has broke the unique e-mail index and answered 500. Both validators
now say the address is taken. The service stores the e-mail in lower case,
as GetUserByEmail looks it up: a mixed-case address slipped past the check
and could not sign in either.
Copilot AI balanced review requested due to automatic review settings November 27, 2026 15:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

…-taken

# Conflicts:
#	src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml
#	src/Web/Grand.Web/App_Data/Resources/Upgrade/en_250.xml
@grandnode-dev
grandnode-dev merged commit 9a3407e into develop Nov 27, 2026
9 checks passed
@grandnode-dev
grandnode-dev deleted the fix/api-user-email-taken branch November 27, 2026 21:48
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.

2 participants