From f2cdce29953391437018fcc69d08451d4b4a17f2 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 10 Mar 2016 16:32:29 +0100 Subject: * refactoring password hash/verify methods --- app/php/user/DbUser.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/php/user/DbUser.php') diff --git a/app/php/user/DbUser.php b/app/php/user/DbUser.php index c8459fa..bb6f78e 100644 --- a/app/php/user/DbUser.php +++ b/app/php/user/DbUser.php @@ -37,7 +37,7 @@ class DbUser extends TDbUser { public function validateUser($login, $password) { $user = User::finder()->findByLogin($login); $dbPassword = $user ? $user->Password : ''; - if (password_verify($password, $dbPassword) && $user) { + if (self::verifyPassword($password, $dbPassword) && $user) { $user->LastLogin = date('Y-m-d H:i:s'); $user->save(); return TRUE; @@ -62,6 +62,14 @@ class DbUser extends TDbUser { } } + public static function generatePassword($password) { + return password_hash($password, PASSWORD_DEFAULT); + } + + public static function verifyPassword($password, $dbPassword) { + return password_verify($password, $dbPassword); + } + } ?> -- cgit v1.2.3