Warning

This document hasn't been checked for compatibility with current versions of Plone. Use at your own risk.

Ensure that deleted users can not re-register and gain control of their previouis folders

by Simon Judge last modified Dec 30, 2008 03:02 PM
You may want to be able to delete naughty users from your site, but keep any content they may have created... However, default behaviour allows the users to re-register with the same user name and regain their existing folder. This fix stops that...

This only applies if you keep a  user's folder once you have deleted the user (i.e.  if delete_memberareas=0 is set in prefs_user_manage.cpy ).

This may be an ugly hack, there are probably better ways to do it!

Create a custom validation script:


Add the following script to your product/custom skin:

## Script (Python) "isMemberAllowed"
##parameters=id
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##title=Check that a member doesn't exist AND hasn't previously existed.
##

reg_tool=context.portal_registration
membership = context.portal_membership

if reg_tool.isMemberIdAllowed(id) is None or membership.getHomeFolder(id) is not None:
    return 0
return 1

Modify the join form validation:


Customise the appropriate line in join_form_validate.cpy to:

if not state.getError('username') and not context.isMemberAllowed(username):

Job done. Test this yourself, obviously.



Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.