Auth Db: use helper methods to retrieve data instead of FPDO raw methods
This commit is contained in:
parent
dbf5b0a54c
commit
20461e3e47
1 changed files with 11 additions and 15 deletions
|
@ -86,13 +86,11 @@ class Db extends Backend {
|
|||
public static function get_user($username) {
|
||||
self :: connect();
|
||||
try {
|
||||
$query = self :: $class :: $fpdo -> from(self :: $users_table)
|
||||
-> select(null)
|
||||
-> select(self :: $exposed_fields)
|
||||
-> where(self :: $username_field, $username);
|
||||
|
||||
$result = $query -> execute();
|
||||
$info = $result -> fetch();
|
||||
$info = self :: $class :: get_one(
|
||||
self :: $users_table,
|
||||
[self :: $username_field => $username],
|
||||
self :: $exposed_fields
|
||||
);
|
||||
if ($info === false)
|
||||
return null;
|
||||
return new User($username, '\\EesyPHP\\Auth\\Db', $info);
|
||||
|
@ -112,16 +110,14 @@ class Db extends Backend {
|
|||
public static function check_password($user, $password) {
|
||||
self :: connect();
|
||||
try {
|
||||
$query = self :: $class :: $fpdo -> from(self :: $users_table)
|
||||
-> select(null)
|
||||
-> select(self :: $password_field)
|
||||
-> where(self :: $username_field, $user->username);
|
||||
|
||||
$result = $query -> execute();
|
||||
$info = $result -> fetch();
|
||||
$info = self :: $class :: get_one(
|
||||
self :: $users_table,
|
||||
[self :: $username_field => $user->username],
|
||||
[self :: $password_field]
|
||||
);
|
||||
if ($info === false)
|
||||
return false;
|
||||
return password_verify($password, $info['password']);
|
||||
return password_verify($password, $info[self :: $password_field]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Log :: error("Error retrieving user %s password from database: %s", $user, $e->getMessage());
|
||||
|
|
Loading…
Reference in a new issue