eggification
[GroupUserFolder.git] / Products / GroupUserFolder / skins / gruf / change_password.py
diff --git a/Products/GroupUserFolder/skins/gruf/change_password.py b/Products/GroupUserFolder/skins/gruf/change_password.py
new file mode 100644 (file)
index 0000000..cd3f97f
--- /dev/null
@@ -0,0 +1,31 @@
+## Script (Python) "change_password"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=password, confirm, domains=None
+##title=Change password
+##
+
+pass
+
+## This code is there because there's a bug in CMF that prevents
+## passwords to be changed if the User Folder doesn't store it in a __
+## attribute.
+## This includes User Folders such as LDAPUF, SimpleUF, and, of course, GRUF.
+## This also includes standard UF with password encryption !
+
+mt = context.portal_membership
+failMessage=context.portal_registration.testPasswordValidity(password, confirm)
+
+if failMessage:
+    return context.password_form(context,
+                                 context.REQUEST,
+                                 error=failMessage)
+context.REQUEST['AUTHENTICATED_USER'].changePassword(password,REQUEST=context.REQUEST)
+mt.credentialsChanged(password)
+return context.personalize_form(context,
+                                context.REQUEST,
+                                portal_status_message='Password changed.')
+