Opened 10 years ago
Last modified 5 years ago
#11894 closed enhancement
User Name policy configurable? — at Version 2
Reported by: | anonymous | Owned by: | Steffen Hoffmann |
---|---|---|---|
Priority: | normal | Component: | AccountManagerPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: |
Description (last modified by )
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 loaded from the ini 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.
Change History (2)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Description: | modified (diff) |
---|
Note: See
TracTickets for help on using
tickets.
Actually I (am the same as the reporter, I just registered afterwards) changed manually the could and rebuilt and update the plugin... but still get the error
"Username abc doesn't match local naming policy."