Skip to content

fix(db): keep the OAuth2 provider username on signup - #1159

Open
mfuhrmann wants to merge 1 commit into
open-wanderer:devfrom
osm-fulda:oidc-username
Open

fix(db): keep the OAuth2 provider username on signup#1159
mfuhrmann wants to merge 1 commit into
open-wanderer:devfrom
osm-fulda:oidc-username

Conversation

@mfuhrmann

Copy link
Copy Markdown

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 generated usersNNNNNN name.

This transliterates accented characters (Karl DörfingerKarl_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.

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.
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.

1 participant