diff --git a/_sakura/components/Users.php b/_sakura/components/Users.php index 3ee2d2c..89febfd 100644 --- a/_sakura/components/Users.php +++ b/_sakura/components/Users.php @@ -77,6 +77,10 @@ class Users { // Log a user in public static function login($username, $password, $remember = false) { + // Check if authentication is disallowed + if(Configuration::getConfig('lock_authentication')) + return [0, 'AUTH_LOCKED']; + // Check if the user that's trying to log in actually exists if(!$uid = self::userExists($username, false)) return [0, 'USER_NOT_EXIST']; @@ -145,6 +149,10 @@ class Users { // Register user public static function register($username, $password, $confirmpass, $email, $tos, $captcha = null, $regkey = null) { + // Check if authentication is disallowed + if(Configuration::getConfig('lock_authentication')) + return [0, 'AUTH_LOCKED']; + // Check if registration is even enabled if(Configuration::getConfig('disable_registration')) return [0, 'DISABLED']; @@ -182,18 +190,6 @@ class Users { if(strlen($username) > 16) return [0, 'NAME_TOO_LONG']; - // Password too short - if(strlen($password) < 8) - return [0, 'PASS_TOO_SHORT']; - - // Password too long - if(strlen($password) > 256) - return [0, 'PASS_TOO_LONG']; - - // Passwords do not match - if($password != $confirmpass) - return [0, 'PASS_NOT_MATCH']; - // Check if the given email address is formatted properly if(!filter_var($email, FILTER_VALIDATE_EMAIL)) return [0, 'INVALID_EMAIL']; @@ -202,6 +198,14 @@ class Users { if(!Main::checkMXRecord($email)) return [0, 'INVALID_MX']; + // Check password entropy + if(Main::pwdEntropy($password) < Configuration::getConfig('min_entropy')) + return [0, 'PASS_TOO_SHIT']; + + // Passwords do not match + if($password != $confirmpass) + return [0, 'PASS_NOT_MATCH']; + // Set a few variables $usernameClean = Main::cleanString($username, true); $emailClean = Main::cleanString($email, true); @@ -257,6 +261,10 @@ class Users { // Check if a user exists and then resend the activation e-mail public static function resendActivationMail($username, $email) { + // Check if authentication is disallowed + if(Configuration::getConfig('lock_authentication')) + return [0, 'AUTH_LOCKED']; + // Clean username string $usernameClean = Main::cleanString($username, true); $emailClean = Main::cleanString($email, true); diff --git a/_sakura/sakura.php b/_sakura/sakura.php index 0f19861..f344de3 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20150421'); +define('SAKURA_VERSION', '20150424'); // Define Sakura Path define('ROOT', str_replace(basename(__DIR__), '', dirname(__FILE__))); @@ -60,6 +60,7 @@ $renderData = array( 'recaptcha_enable' => Configuration::getConfig('recaptcha'), 'resources' => '//'. Configuration::getLocalConfig('urls')['content'] .'/data/'. strtolower(Templates::$_TPL), 'disableregister' => Configuration::getConfig('disable_registration'), + 'lockauth' => Configuration::getConfig('lock_authentication'), 'requireregcodes' => Configuration::getConfig('require_registration_code'), 'requireactiveate' => Configuration::getConfig('require_activation'), 'sitename' => Configuration::getConfig('sitename') diff --git a/_sakura/templates/yuuno/global/header.tpl b/_sakura/templates/yuuno/global/header.tpl index 00b42ae..1a477ae 100644 --- a/_sakura/templates/yuuno/global/header.tpl +++ b/_sakura/templates/yuuno/global/header.tpl @@ -17,7 +17,7 @@