From: ivan Date: Fri, 26 Apr 2002 11:14:37 +0000 (+0000) Subject: add username-nounderscore and username-nodash config files X-Git-Tag: freeside_1_4_0_pre12~16 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=da1388d2f8196c2240ad0bc5debc925618d71806 add username-nounderscore and username-nodash config files --- diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 3565be965..6e45ec052 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -779,6 +779,20 @@ httemplate/docs/config.html }, { + 'key' => 'username-nounderscore', + 'section' => 'username', + 'description' => 'Disallow underscores in usernames', + 'type' => 'checkbox', + }, + + { + 'key' => 'username-nodash', + 'section' => 'username', + 'description' => 'Disallow dashes in usernames', + 'type' => 'checkbox', + }, + + { 'key' => 'username-uppercase', 'section' => 'username', 'description' => 'Allow uppercase characters in usernames', diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index d3c415ce3..bb8c5e21e 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -5,7 +5,8 @@ use vars qw( @ISA $noexport_hack $conf $dir_prefix @shells $usernamemin $usernamemax $passwordmin $passwordmax $username_ampersand $username_letter $username_letterfirst - $username_noperiod $username_uppercase + $username_noperiod $username_nounderscore $username_nodash + $username_uppercase $mydomain $dirhash @saltset @pw_set ); @@ -40,6 +41,8 @@ $FS::UID::callback{'FS::svc_acct'} = sub { $username_letter = $conf->exists('username-letter'); $username_letterfirst = $conf->exists('username-letterfirst'); $username_noperiod = $conf->exists('username-noperiod'); + $username_nounderscore = $conf->exists('username-nounderscore'); + $username_nodash = $conf->exists('username-nodash'); $username_uppercase = $conf->exists('username-uppercase'); $username_ampersand = $conf->exists('username-ampersand'); $mydomain = $conf->config('domain'); @@ -547,6 +550,12 @@ sub check { if ( $username_noperiod ) { $recref->{username} =~ /\./ and return gettext('illegal_username'); } + if ( $username_nounderscore ) { + $recref->{username} =~ /_/ and return gettext('illegal_username'); + } + if ( $username_nodash ) { + $recref->{username} =~ /\-/ and return gettext('illegal_username'); + } unless ( $username_ampersand ) { $recref->{username} =~ /\&/ and return gettext('illegal_username'); }