diff options
author | emkael <emkael@tlen.pl> | 2016-03-10 16:32:29 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-03-10 16:32:29 +0100 |
commit | f2cdce29953391437018fcc69d08451d4b4a17f2 (patch) | |
tree | bef0886767dc424967e00e20962d75a58752c586 /app/php/user/DbUser.php | |
parent | 244aed5334194dd11e86541ec11445c72f70e1e8 (diff) |
* refactoring password hash/verify methods
Diffstat (limited to 'app/php/user/DbUser.php')
-rw-r--r-- | app/php/user/DbUser.php | 10 |
1 files changed, 9 insertions, 1 deletions
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); + } + } ?> |