diff options
Diffstat (limited to 'app/Utils/passwordUtil.php')
| -rw-r--r-- | app/Utils/passwordUtil.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/app/Utils/passwordUtil.php b/app/Utils/passwordUtil.php index cff97d2bc..0edead213 100644 --- a/app/Utils/passwordUtil.php +++ b/app/Utils/passwordUtil.php @@ -3,26 +3,25 @@ class FreshRSS_password_Util { // Will also have to be computed client side on mobile devices, // so do not use a too high cost - const BCRYPT_COST = 9; + public const BCRYPT_COST = 9; /** * Return a hash of a plain password, using BCRYPT - * - * @param string $passwordPlain - * @return string */ - public static function hash($passwordPlain) { + public static function hash(string $passwordPlain): string { $passwordHash = password_hash( $passwordPlain, PASSWORD_BCRYPT, array('cost' => self::BCRYPT_COST) ); - $passwordPlain = ''; // Compatibility with bcrypt.js $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); - return $passwordHash == '' ? '' : $passwordHash; + if ($passwordHash === '' || $passwordHash === null) { + return ''; + } + return $passwordHash; } /** @@ -30,11 +29,9 @@ class FreshRSS_password_Util { * * A valid password is a string of at least 7 characters. * - * @param string $password - * - * @return boolean True if the password is valid, false otherwise + * @return bool True if the password is valid, false otherwise */ - public static function check($password) { + public static function check(string $password): bool { return strlen($password) >= 7; } } |
