Opened 9 years ago
Last modified 4 years ago
#11894 closed enhancement
User Name policy configurable? — at Initial Version
| Reported by: | anonymous | Owned by: | Steffen Hoffmann |
|---|---|---|---|
| Priority: | normal | Component: | AccountManagerPlugin |
| Severity: | normal | Keywords: | |
| Cc: | Trac Release: |
Description
It seems it is hard coded the username policy. I think it would be nice if it could be configured in the trac.ini file.
Example, I don't want the minimum of 5 chars long user names. I found the code, but I don't know python. register.py:
username_regexp = Option('account-manager', 'username_regexp',
r'(?i)^[A-Z0-9.\-_]{5,}$',
doc="A validation regular expression describing new usernames.")
couldn't it be laoded from the inii file like:
def validate_registration(self, req):
acctmgr = AccountManager(self.env)
""" New """
regexp = req.args.get('username.regexp', '');
if regexp=""
username_regexp = Option('account-manager', 'username_regexp',
r'(?i)^[A-Z0-9.\-_]{5,}$',
doc="A validation regular expression describing new usernames.")
else:
username_regexp = Option('account-manager', 'username_regexp',
regexp, """ Notice I dont know how to handle the r'...' """
doc="A validation regular expression describing new usernames.")
""" End new
username = acctmgr.handle_username_casing(
req.args.get('username', '').strip())
if self.username_regexp != "" and \
not re.match(self.username_regexp.strip(), username):
raise RegistrationError(N_(
"Username %s doesn't match local naming policy."),
tag.b(username)
)
...
Of course cleaning up constants and so on.
Note: See
TracTickets for help on using
tickets.


