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

Notify user events on creation and authentication #58

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/53.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Notify user events on creation and authentication. [@Arkusm][@ericof]
13 changes: 11 additions & 2 deletions src/pas/plugins/oidc/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from plone.protect.utils import safeWrite
from Products.CMFCore.utils import getToolByName
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PlonePAS.events import UserInitialLoginInEvent
from Products.PlonePAS.events import UserLoggedInEvent
from Products.PluggableAuthService.events import PrincipalCreated
from Products.PluggableAuthService.interfaces.plugins import IAuthenticationPlugin
from Products.PluggableAuthService.interfaces.plugins import IChallengePlugin
from Products.PluggableAuthService.interfaces.plugins import IUserAdderPlugin
Expand All @@ -18,6 +21,7 @@
from secrets import choice
from typing import List
from ZODB.POSException import ConflictError
from zope.event import notify
from zope.interface import implementer
from zope.interface import Interface

Expand Down Expand Up @@ -214,12 +218,17 @@ def rememberIdentity(self, userinfo):
# depending on your setup.
# https://bandit.readthedocs.io/en/1.7.4/plugins/b110_try_except_pass.html
pass
self._updateUserProperties(user, userinfo)
break
else:
notify(PrincipalCreated(user))
self._updateUserProperties(user, userinfo)
notify(UserInitialLoginInEvent(user))
notify(UserLoggedInEvent(user))
break
else:
# if time.time() > user.getProperty(LAST_UPDATE_USER_PROPERTY_KEY) + config.get(autoUpdateUserPropertiesIntervalKey, 0):
with safe_write(self.REQUEST):
self._updateUserProperties(user, userinfo)
notify(UserLoggedInEvent(user))

if self.getProperty("create_groups"):
groupid_property = self.getProperty("user_property_as_groupid")
Expand Down
Loading