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

fix: apply provided nickname in signup modal #9

Closed
wants to merge 1 commit into from

Conversation

blt950
Copy link

@blt950 blt950 commented Jun 27, 2024

Related to #8 (comment)

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 is 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 relecting 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 fallsback 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)

Today if you supply through an OAuth2 client a nickname, the signup modal will not respect this and still override the nickname input field with the username. 

However with this fix, you can get OAuth2 to put `username` based on id and `nickname ` with a UTF-8 characters and no restrictions.
@luceos
Copy link
Member

luceos commented Jun 27, 2024

Hello @blt950, namesake,

Thank you so much for your contribution. It means a lot to us that you've taken the time to initiate the Pull Request. However, this is a read only repository; flarum/nicknames is actually part of our source repository at https://github.com/flarum/framework/tree/main/extensions/nicknames. For this reason we cannot review this PR, but we would in case it is made against the framework repository.

Let me know if you have any questions to make this change possible.

@luceos luceos closed this Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants