fix(db): keep the OAuth2 provider username on signup - #1159
Open
mfuhrmann wants to merge 1 commit into
Open
Conversation
PocketBase only maps the provider username when the raw value already satisfies users.username (^[\w][\w.\-]*$, min 3), so OSM display names with spaces or umlauts get a generated usersNNNNNN name instead. Transliterate accented characters, replace what is left over, and resolve collisions before assigning. Assigning the raw value fails record validation and breaks signup entirely.
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.
Fixes root cause 2 of #1026.
PocketBase only maps the provider username when the raw value already satisfies
users.username(^[\w][\w.\-]*$, min 3). OSM display names contain spaces and umlauts, so accounts end up with a generatedusersNNNNNNname.This transliterates accented characters (
Karl Dörfinger→Karl_Doerfinger), replaces anything left over with underscores, and resolves collisions with a numeric suffix. When nothing usable remains the username is left unset and PocketBase generates one as before.Assigning the raw value instead is not an option: record validation rejects it, so signup fails outright.
Tested with OSM logins on a self-hosted instance; unit tests in
db/util/username_test.go.