mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 00:25:18 +00:00
Can check user password in $_POST request
This commit is contained in:
@ -198,6 +198,32 @@ class AccountComponent {
|
||||
return CS::get()->db->addLine(self::USER_TABLE, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a password is valid for a user
|
||||
*
|
||||
* @param int $userID Target user ID : The ID of the user to check
|
||||
* @param string $password The password to check
|
||||
* @return bool TRUE if the password is valid / FALSE else
|
||||
*/
|
||||
public function checkUserPassword(int $userID, string $password){
|
||||
|
||||
//Crypt password
|
||||
$password = $this->cryptPassword($password);
|
||||
|
||||
//Prepare request over the database
|
||||
$conditions = array(
|
||||
"ID" => $userID,
|
||||
"password" => $password
|
||||
);
|
||||
|
||||
$data = CS::get()->db->splitConditionsArray($conditions);
|
||||
$sql_conds = "WHERE ".$data[0];
|
||||
$values = $data[1];
|
||||
|
||||
//Perform request and return result
|
||||
return CS::get()->db->count(self::USER_TABLE, $sql_conds, $values) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crypt user password
|
||||
*
|
||||
|
Reference in New Issue
Block a user