feat(nicknames): allow OAuth to provide a nickname #4004
Merged
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.
Changes proposed in this pull request:
Scenario: User logins with OAuth2, the OAuth server provides and numeric
id
and a stringnickname
such as "Robert Lan". This nickname is not valid as username in Flarum and will fail the regex validation. Hence I wish to set the user's name as nickname as it can't be a username.Purpose of change: Today the Nickname signup modal doesn't respect code to provide nickname when username is also supplied.
This ends up with both nickname and username fields just replacing the username. This is because of this line
framework/extensions/nicknames/js/src/forum/index.js
Line 60 in 873db6e
What has changed
I've just added a check for
attr.nickname
before it falls back tousername
or blank. This seems to solve the issue.Necessity
Confirmed
composer test
).Required changes: