From 5c3f6bb530a6d3939be820ef69fd694aae3875a5 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Tue, 23 May 2017 22:36:26 +0200 Subject: [PATCH] Always return valid regex --- helpers/config.php | 8 ++++---- helpers/user.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/helpers/config.php b/helpers/config.php index 6a62f7a..ec4e1c3 100644 --- a/helpers/config.php +++ b/helpers/config.php @@ -164,7 +164,7 @@ * Valid for both php and javascript */ public static function passRegex() { - static $regex = ""; + $regex = ""; if (self::$pass_strength > 0) { // lower and upper case $regex .= "(?=.*[a-z])(?=.*[A-Z])"; @@ -180,10 +180,10 @@ if (self::$pass_lenmin > 0) { $regex .= "(?=.{" . self::$pass_lenmin . ",})"; } - if (!empty($regex)) { - $regex = "/" . $regex . "/"; + if (empty($regex)) { + $regex = ".*"; } - return $regex; + return "/" . $regex . "/"; } } diff --git a/helpers/user.php b/helpers/user.php index e144890..752cdd3 100644 --- a/helpers/user.php +++ b/helpers/user.php @@ -125,7 +125,7 @@ */ public function setPass($pass) { $ret = false; - if ($this->validPassStrength($pass)) { + if (!empty($this->login) && !empty($pass) && $this->validPassStrength($pass)) { $hash = password_hash($pass, PASSWORD_DEFAULT); $sql = "UPDATE `" . self::$db->table('users') . "` SET password = ? WHERE login = ?"; $stmt = self::$db->prepare($sql);