Add list of reserved usernames

This commit is contained in:
Daniel Winzen 2022-07-31 21:07:52 +02:00
parent bb247d295c
commit ee9f0b0714
No known key found for this signature in database
GPG key ID: 222FCC3F35C41077
2 changed files with 5 additions and 0 deletions

View file

@ -12,6 +12,7 @@ const DBNAME = 'postfix'; // Database
const DBVERSION = 1; // Database schema version const DBVERSION = 1; // Database schema version
const PERSISTENT = true; // persistent database connection const PERSISTENT = true; // persistent database connection
const CAPTCHA_DIFFICULTY = 1; // captcha difficulty from 0 to 3 const CAPTCHA_DIFFICULTY = 1; // captcha difficulty from 0 to 3
const RESERVED_USERNAMES = ['about', 'abuse', 'admin', 'administrator', 'billing', 'contact', 'daemon', 'ftp', 'help', 'hostmaster', 'info', 'legal', 'list', 'list-request', 'lists', 'maildaemon', 'mailerdaemon', 'mailer-daemon', 'marketing', 'media', 'news', 'newsletter', 'nobody', 'noc', 'noreply', 'no-reply', 'notification', 'notifications', 'notify', 'offer', 'offers', 'office', 'official', 'order', 'orders', 'phish', 'phishing', 'postmaster', 'root', 'sale', 'sales', 'security', 'service', 'services', 'shop', 'shopping', 'spam', 'staff', 'support', 'survey', 'system', 'team', 'teams', 'unsbubscribe', 'uucp', 'usenet', 'user', 'username', 'users', 'web', 'webmail', 'webmaster', 'webmasters', 'welcome', 'www']; // list of reserved usernames that can mot be used on public registration
require_once( 'vendor/autoload.php' ); require_once( 'vendor/autoload.php' );

View file

@ -47,7 +47,11 @@ if ( isset( $_POST[ 'user' ] ) ) {
if ( ! $validator->isValid( "$user@$domain", new NoRFCWarningsValidation() ) ) { if ( ! $validator->isValid( "$user@$domain", new NoRFCWarningsValidation() ) ) {
$ok = false; $ok = false;
$msg .= '<div class="red" role="alert">The email address you specified is not valid</div>'; $msg .= '<div class="red" role="alert">The email address you specified is not valid</div>';
} elseif(in_array($user, RESERVED_USERNAMES, true)){
$ok = false;
$msg .= '<div class="red" role="alert">The user name you specified is reserved</div>';
} }
} }
} }
if ( $ok ) { if ( $ok ) {