Skip to content

Conversation

@AndrewPrigorshnev
Copy link
Contributor

@AndrewPrigorshnev AndrewPrigorshnev commented Oct 18, 2021

This addresses comments of @gschlager to #14531:

  • extracts the common logic of overriding usernames into separate method
  • fixes usernames comparison when checking if a username should be overridden. We should unicode normalize a new username before comparison, not only down case it. Note also that this logic was extracted into a separate method:

    discourse/app/models/user.rb

    Lines 1441 to 1443 in 78cfaa6

    def username_equals_to?(another_username)
    username_lower == User.normalize_username(another_username)
    end
  • adds using of UsernameChanger instead of just setting a new username in order to update quotes and mentions when renaming (which addresses this complaint https://meta.discourse.org/t/updating-mentions-when-username-is-changed-via-sso/202992)

@AndrewPrigorshnev AndrewPrigorshnev changed the title DEV: extract and fix overriding of usernames by external auth FIX: extract and fix overriding of usernames by external auth Oct 18, 2021
@AndrewPrigorshnev AndrewPrigorshnev merged commit 1c0022c into main Dec 2, 2021
@AndrewPrigorshnev AndrewPrigorshnev deleted the dev/extract-username-overrider branch December 2, 2021 13:42
@discoursebot
Copy link

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/updating-mentions-when-username-is-changed-via-sso/202992/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants