Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Currently the synchronization of username and password happening on every login via hook_user_login. There is a @todo mentioned, which says that this should be configurable.
Proposed resolution
- Add new config + possibility to change this in admin form
- Add new method to the manager class which handles the synchronization.
- Force sync while external register
Remaining tasks
- Provide patch.
Comments
Comment #2
eyilmazHere is the patch.
Comment #3
eyilmazComment #4
snufkin CreditAttribution: snufkin commentedSome changes went into the D8 branch, could you reroll the patch please?
Comment #5
eyilmazrerolled patch.
Comment #6
eyilmazComment #7
svendecabooterNice improvement! The code looks good to me, and works as advertised in my tests, except for a few minor things (see below).
I updated the patch by eyilmaz slightly in the attached patch:
The call to synchronizeUserAttributes to force saving of user attributes in externalRegister() might need some improvement in a followup patch, since now we might be saving the user account 3 times upon registration:
I'll give some thought on how to improve that, but that seems to be out of scope of this issue, so will do that in a followup issue.
Comment #9
snufkin CreditAttribution: snufkin commentedFixed, thanks to both of you. I've put eylmaz as the commit author, as he proposed the initial big patch.
Comment #11
malik.kotob CreditAttribution: malik.kotob commentedQuestion for you all. What's the rationale behind forcing the sync for external registrations? We currently have a use case where the username in Drupal matches the authname from the IdP, and the existing account is linked with that. The email address, however, does not match the email address from the IdP, and we were hoping to keep it that way. Instead, it's being synced despite our config settings (because it's forced).