Skip to content

Commit

Permalink
Merge pull request #106 from zopefoundation/updateCredentials_login#105
Browse files Browse the repository at this point in the history
Pass user name as login to updateCredentials - fix #105
  • Loading branch information
d-maurer committed Dec 28, 2021
2 parents 91dbe53 + bb63582 commit 12c873e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CHANGES.rst
Expand Up @@ -4,7 +4,10 @@ Change Log
2.6.5 (unreleased)
------------------

- Nothing changed yet.
- Pass the login name as ``updateCredentials``'s ``login`` parameter
(not the user id) (`#105
<https://github.com/zopefoundation/Products.PluggableAuthService/issues/105>`_).
Fix docstring of ``PluggableAuthService._extractUserIds``.


2.6.4 (2021-07-28)
Expand Down
6 changes: 3 additions & 3 deletions src/Products/PluggableAuthService/PluggableAuthService.py
Expand Up @@ -531,11 +531,11 @@ def _isNotCompetent(self, request, plugins):

@security.private
def _extractUserIds(self, request, plugins):
""" request -> [validated_user_id]
""" request -> [(validated_user_id, login)]
o For each set of extracted credentials, try to authenticate
a user; accumulate a list of the IDs of such users over all
our authentication and extraction plugins.
a user; accumulate a list of pairs (ID, login) of such users
over all our authentication and extraction plugins.
"""
try:
extractors = plugins.listPlugins(IExtractionPlugin)
Expand Down
2 changes: 1 addition & 1 deletion src/Products/PluggableAuthService/events.py
Expand Up @@ -97,7 +97,7 @@ def userCredentialsUpdatedHandler(principal, event):
pas.updateCredentials(
pas.REQUEST,
pas.REQUEST.RESPONSE,
principal.getId(),
principal.getUserName(), # aka "login"
event.password)


Expand Down
2 changes: 2 additions & 0 deletions src/Products/PluggableAuthService/tests/pastc.py
Expand Up @@ -57,6 +57,8 @@ def _setupUserFolder(self):
plugins.activatePlugin(IRolesPlugin, 'roles')
plugins.activatePlugin(IRoleAssignerPlugin, 'roles')
plugins.activatePlugin(IRoleEnumerationPlugin, 'roles')
# add a user for which id and login are different
plugins.users.addUser("user_id", "user_login", "user_password")

def _setupUser(self):
"""Creates the default user."""
Expand Down
4 changes: 2 additions & 2 deletions src/Products/PluggableAuthService/tests/test_UserFolder.py
Expand Up @@ -335,7 +335,7 @@ def wrap(self, *args):
self.uf._original = self.uf.updateCredentials
self.uf.updateCredentials = functools.partial(wrap, self.uf)
self.assertEqual(len(self.uf._data), 0)
event.notify(CredentialsUpdated(self.uf.getUserById('user1'),
event.notify(CredentialsUpdated(self.uf.getUserById('user_id'),
'testpassword'))
self.assertEqual(self.uf._data[0][2], 'user1')
self.assertEqual(self.uf._data[0][2], 'user_login')
self.assertEqual(self.uf._data[0][3], 'testpassword')

0 comments on commit 12c873e

Please sign in to comment.