collective / pas.plugins.oidc

PAS plugin for OpenID Connect authentication
Other
3 stars 10 forks source link

Event required to indicate the creation of a new user #53

Open Arkusm opened 2 weeks ago

Arkusm commented 2 weeks ago

During the login process, an attempt is made to create a new user (plone member). I think that IUserAdderPlugin is used for this. Unfortunately no plone event is triggered in this context or I don't know which one. Even if the creation of the user was successful. Normally such an event is always triggered when a new user is created, like here.

My system uses a UsersAsContent implementation and I need such an event to create a new user object.

Can someone tell me if a corresponding event is triggered?

erral commented 2 weeks ago

I tried to do so (https://github.com/collective/pas.plugins.oidc/pull/41) trying to log in the user in portal_membership tool, but I failed because the request is not yet authenticated.

Arkusm commented 2 weeks ago

You could trigger an event in plugins.py.

from Products.PluggableAuthService.events import PrincipalCreated
from zope.event import notify
...
notify(PrincipalCreated(user))  # line 218 befor break

This works. You can then create a subscriber this way

  <!-- New Member created -->
  <subscriber
      for="Products.PluggableAuthService.interfaces.authservice.IPropertiedUser
           Products.PluggableAuthService.interfaces.events.IPrincipalCreatedEvent"
      handler=".updater.new_user"
      />

But I don't know whether this is desired or should be done.

erral commented 2 weeks ago

I think it is desired. It should be so, because there is a specific event for that.