Can you reproduce the bug on the Forgejo test instance?
No, I can't try it on the test instance for some reason
Description
We use OpenID connect (Azure EntraID) for sign in. We link on email address, and accounts are pre populated, all lowercase.
For some reason, some accounts have their email address with uppercase (ie. John.Doe@company.com), and this results in a 500 when the external_login_user does not exist yet.
When trying to create a user (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/routers/web/auth/oauth.go#L1090) the username is the normalized part for the @ (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/routers/web/auth/auth.go#L358). This keeps the upper case (John.Doe).
When creating the user (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/models/user/user.go#L791) IsUserExists checks for the username in lowercase (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/models/user/user.go#L592), which results in an UserAlreadyExists error.
This error is handled in the auth code, which tries to find the user, without lower casing it, resulting in the 500. (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/routers/web/auth/auth.go#L518)
How should this be fixed? Should there be an extra code path which tries to find the user in lowercase in the auth code (createUserInContext) ?
Forgejo Version
13.0.1
How are you running Forgejo?
helm
Logs
No response
Database
PostgreSQL
### Can you reproduce the bug on the Forgejo test instance?
No, I can't try it on the test instance for some reason
### Description
We use OpenID connect (Azure EntraID) for sign in. We link on email address, and accounts are pre populated, all lowercase.
For some reason, some accounts have their email address with uppercase (ie. John.Doe@company.com), and this results in a 500 when the external_login_user does not exist yet.
When trying to create a user (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/routers/web/auth/oauth.go#L1090) the username is the normalized part for the @ (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/routers/web/auth/auth.go#L358). This keeps the upper case (John.Doe).
When creating the user (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/models/user/user.go#L791) IsUserExists checks for the username in lowercase (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/models/user/user.go#L592), which results in an UserAlreadyExists error.
This error is handled in the auth code, which tries to find the user, without lower casing it, resulting in the 500. (https://codeberg.org/forgejo/forgejo/src/branch/forgejo/routers/web/auth/auth.go#L518)
How should this be fixed? Should there be an extra code path which tries to find the user in lowercase in the auth code (createUserInContext) ?
### Forgejo Version
13.0.1
### How are you running Forgejo?
helm
### Logs
_No response_
### Database
PostgreSQL