Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nicknames): allow OAuth to provide a nickname #4004

Merged
merged 2 commits into from
Oct 22, 2024
Merged

Conversation

blt950
Copy link
Contributor

@blt950 blt950 commented Jun 28, 2024

Changes proposed in this pull request:

Scenario: User logins with OAuth2, the OAuth server provides and numeric id and a string nickname 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.

Example from OAuth call
->provide('username', $user->getId())
->provide('nickname', $user->getName())

This ends up with both nickname and username fields just replacing the username. This is because of this line

this.nickname = Stream(this.attrs.username || '');
which only fetches a copy of the username in the nickname box. This is an issue because if you provide (instead of suggesting), the user should not be able to edit this field, though it's even more important that the provided value is displayed.

What has changed
I've just added a check for attr.nickname before it falls back to username or blank. This seems to solve the issue.

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

Required changes:

  • Related documentation PR: (Remove if irrelevant)
  • Related core extension PRs: (Remove if irrelevant)

@blt950 blt950 requested a review from a team as a code owner June 28, 2024 08:42
@SychO9 SychO9 changed the title fix: apply provided nickname in signup modal feat(nicknames): allow OAuth to provide a nickname Oct 22, 2024
@SychO9 SychO9 added this to the 2.0 milestone Oct 22, 2024
Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

Thanks!

@SychO9 SychO9 merged commit f51df1c into flarum:2.x Oct 22, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants