+ Fixed bug when resetting password

This commit is contained in:
Djery-Tom 2020-10-21 14:59:10 +01:00
parent 86ee7af249
commit 59a61c1d98
3 changed files with 48 additions and 6 deletions

View File

@ -153,6 +153,19 @@ class DataBaseConnector
}
public function isPhoneExistedAgent($phone){
$result = mysqli_query($this->con,"SELECT * FROM networks_agents WHERE transactionNumber ='$phone' OR phone ='$phone' LIMIT 1");
if($result) {
$no_of_rows = mysqli_num_rows($result);
if ($no_of_rows > 0) {
return mysqli_fetch_array($result);
}
}else echo json_encode(mysqli_error($this->con));
return false;
}
/**
* @param $phone
* @return bool
@ -558,6 +571,17 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
}
}
public function forgotPasswordAgent($agent_id, $encrypted_password, $salt)
{
$result = mysqli_query($this->con, "UPDATE `agents` SET `encrypted_password` = '$encrypted_password',`salt` = '$salt' WHERE `id` = '$agent_id'");
if ($result) {
return true;
} else {
return false;
}
}
/**
* @param $phone
* @return array|bool|null
@ -577,6 +601,21 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
}
public function getEmailAgent($agent_id){
$result = mysqli_query($this->con,"SELECT email FROM agents WHERE id = '$agent_id'");
if ($result) {
return mysqli_fetch_array($result);
//return true;
}
else
{
return false;
}
}
/**
* @return array|null
*/

View File

@ -194,14 +194,15 @@ class Requester
*/
public function recoverPasswordAgent($number)
{
if ($this->db->isPhoneExistedSimple($number)) {
$result = $this->db->isPhoneExistedAgent($number);
if ($result) {
$randomcode = $this->db->random_string();
$hash = $this->db->hashSSHA($randomcode);
$encrypted_password = $hash["encrypted"]; // encrypted password
$salt = $hash["salt"];
$user = $this->db->forgotPasswordSimple($number, $encrypted_password, $salt);
$user = $this->db->forgotPasswordAgent($result['agent_id'], $encrypted_password, $salt);
if ($user) {
$mail = $this->db->getEmailSimple($number);
$mail = $this->db->getEmailAgent($result['agent_id']);
if ($mail) {
$subject = "Password Recovery";
$message = sprintf($this->messageText['TEXT_RECOVERY_PASSWORD'],$randomcode);
@ -598,10 +599,10 @@ class Requester
public function sendPushNotificationToAgent($agent_code, $message, $data = null)
{
$client = new \GuzzleHttp\Client([
'base_uri' => 'localhost:8083',
'base_uri' => NOTIFICATION_SERVICE_URL,
]);
$headers = [
'Authorization' => 'RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg',
'Authorization' => NOTIFICATION_SERVICE_KEY,
];
$body = new \stdClass();
$body->agent_code = $agent_code;

View File

@ -5,6 +5,8 @@ define("DB_HOST", "localhost");
define("DB_USER", "root");
define("DB_PASSWORD", "vps@2017GA");
#define("DB_DATABASE","iLink_test2");
define("DB_DATABASE","iLink_cannary");
define("DB_DATABASE","iLink_preprod");
define("GEOLOCATED_AGENT_ETAT",0);
define("NOTIFICATION_SERVICE_URL",'localhost:8083');
define("NOTIFICATION_SERVICE_KEY",'RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg')
?>