Always return valid regex

This commit is contained in:
Bartek Fabiszewski 2017-05-23 22:36:26 +02:00
parent 67f407635b
commit 5c3f6bb530
2 changed files with 5 additions and 5 deletions

View File

@ -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 . "/";
}
}

View File

@ -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);