be less strict with usernames.

Allow capital letter but show warning.
This commit is contained in:
katagia 2003-11-05 08:36:48 +00:00
parent 3a8cd4ca1e
commit 4b078a5bc4
3 changed files with 10 additions and 4 deletions

View File

@ -161,6 +161,8 @@ switch ($_POST['select']) {
break; break;
case 'general': case 'general':
if (!$_POST['load']) { if (!$_POST['load']) {
if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username']))
$errors[] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because user and uSer could have the same mail-address.'));
// Write all general attributes into $account_new if no profile should be loaded // Write all general attributes into $account_new if no profile should be loaded
$account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_dn = $_POST['f_general_suffix'];
$account_new->general_username = $_POST['f_general_username']; $account_new->general_username = $_POST['f_general_username'];
@ -169,8 +171,8 @@ switch ($_POST['select']) {
// Check if values are OK and set automatic values. if not error-variable will be set // Check if values are OK and set automatic values. if not error-variable will be set
// Check if Groupname contains only valid characters // Check if Groupname contains only valid characters
if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $account_new->general_username)) if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*$', $account_new->general_username))
$errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !')); $errors[] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
if ($account_new->general_gecos=='') { if ($account_new->general_gecos=='') {
$account_new->general_gecos = $account_new->general_username ; $account_new->general_gecos = $account_new->general_username ;
$errors[] = array('INFO', _('Gecos'), _('Inserted groupname in gecos-field.')); $errors[] = array('INFO', _('Gecos'), _('Inserted groupname in gecos-field.'));

View File

@ -98,6 +98,8 @@ switch ($_POST['select']) {
*/ */
case 'general': case 'general':
if (!$_POST['load']) { if (!$_POST['load']) {
if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username']))
$errors[] = array('WARN', _('Hostname'), _('You are using a capital letters. This can cause problems because user and uSer could have the same mail-address.'));
// Write all general values into $account_new if no profile should be loaded // Write all general values into $account_new if no profile should be loaded
$account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_dn = $_POST['f_general_suffix'];
$account_new->general_username = $_POST['f_general_username']; $account_new->general_username = $_POST['f_general_username'];

View File

@ -210,6 +210,8 @@ switch ($_POST['select']) {
break; break;
case 'general': case 'general':
if (!$_POST['load']) { if (!$_POST['load']) {
if (($account_new->general_username != $_POST['f_general_username']) && ereg('[A-Z]$', $_POST['f_general_username']))
$errors[] = array('WARN', _('Username'), _('You are using a capital letters. This can cause problems because user and uSer could have the same mail-address.'));
// Write all general values into $account_new if no profile should be loaded // Write all general values into $account_new if no profile should be loaded
$account_new->general_dn = $_POST['f_general_suffix']; $account_new->general_dn = $_POST['f_general_suffix'];
$account_new->general_username = $_POST['f_general_username']; $account_new->general_username = $_POST['f_general_username'];
@ -230,8 +232,8 @@ switch ($_POST['select']) {
} }
if ($account_new->general_group=='') $errors[] = array('ERROR', _('Primary group'), _('No primary group defined!')); if ($account_new->general_group=='') $errors[] = array('ERROR', _('Primary group'), _('No primary group defined!'));
// Check if Username contains only valid characters // Check if Username contains only valid characters
if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $account_new->general_username)) if ( !ereg('^([a-z]|[A-Z]|[0-9]|[.]|[-]|[_])*$', $account_new->general_username))
$errors[] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !')); $errors[] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
// Check if user already exists // Check if user already exists
// Remove primary group from additional groups if set. // Remove primary group from additional groups if set.
if (isset($account_new->general_groupadd) && in_array($account_new->general_group, $account_new->general_groupadd)) { if (isset($account_new->general_groupadd) && in_array($account_new->general_group, $account_new->general_groupadd)) {