Closed (fixed)
Project:
SAML Authentication
Version:
8.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
31 May 2021 at 08:08 UTC
Updated:
29 Jun 2021 at 12:54 UTC
Jump to comment: Most recent
Comments
Comment #2
roderikYou should be able to use an EventSubscriber that subscribes to SamlauthEvents::USER_SYNC events, for things like this. See UserSyncEventSubscriber for an example.
(I'm using the word "example" lightly because you'll want to completely re-do onUserSync() (and the constructor/class variables) in your own copy... but it gets you into the direction. I think what you really want to do is not "change the attributes" but
if ( ? ) $event->getAccount()->setEmail( ? );Comment #3
roderikHm. I see the issue: UserSyncEventSubscriber will throw an exception if the email isn't set in the attribute.
I think (if I understand your use case correctly and this is an issue you are looking to solve for new users only) what should happen is
1) you make your event subscriber and register it with a higher priority as UserSyncEventSubscriber, e.g. (if I'm not mixing up numbers) 75:
...and set the email in there for new accounts
2) I should fix UserSyncEventSubscriber line 205:
Can you test that?
Comment #4
johnwebdev commentedJust implementing the subscriber seems to work. Thanks!
Comment #6
roderikThat's slightly surprising to me because it still feels like the UserSyncEventSubscriber should have been fixed. So I just pushed the change anyway.
(I'm a bit late; had the commit locally for a few days.)