+ Fixed bug when resetting password
This commit is contained in:
parent
86ee7af249
commit
59a61c1d98
|
@ -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
|
* @param $phone
|
||||||
* @return bool
|
* @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
|
* @param $phone
|
||||||
* @return array|bool|null
|
* @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
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -194,14 +194,15 @@ class Requester
|
||||||
*/
|
*/
|
||||||
public function recoverPasswordAgent($number)
|
public function recoverPasswordAgent($number)
|
||||||
{
|
{
|
||||||
if ($this->db->isPhoneExistedSimple($number)) {
|
$result = $this->db->isPhoneExistedAgent($number);
|
||||||
|
if ($result) {
|
||||||
$randomcode = $this->db->random_string();
|
$randomcode = $this->db->random_string();
|
||||||
$hash = $this->db->hashSSHA($randomcode);
|
$hash = $this->db->hashSSHA($randomcode);
|
||||||
$encrypted_password = $hash["encrypted"]; // encrypted password
|
$encrypted_password = $hash["encrypted"]; // encrypted password
|
||||||
$salt = $hash["salt"];
|
$salt = $hash["salt"];
|
||||||
$user = $this->db->forgotPasswordSimple($number, $encrypted_password, $salt);
|
$user = $this->db->forgotPasswordAgent($result['agent_id'], $encrypted_password, $salt);
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$mail = $this->db->getEmailSimple($number);
|
$mail = $this->db->getEmailAgent($result['agent_id']);
|
||||||
if ($mail) {
|
if ($mail) {
|
||||||
$subject = "Password Recovery";
|
$subject = "Password Recovery";
|
||||||
$message = sprintf($this->messageText['TEXT_RECOVERY_PASSWORD'],$randomcode);
|
$message = sprintf($this->messageText['TEXT_RECOVERY_PASSWORD'],$randomcode);
|
||||||
|
@ -598,10 +599,10 @@ class Requester
|
||||||
public function sendPushNotificationToAgent($agent_code, $message, $data = null)
|
public function sendPushNotificationToAgent($agent_code, $message, $data = null)
|
||||||
{
|
{
|
||||||
$client = new \GuzzleHttp\Client([
|
$client = new \GuzzleHttp\Client([
|
||||||
'base_uri' => 'localhost:8083',
|
'base_uri' => NOTIFICATION_SERVICE_URL,
|
||||||
]);
|
]);
|
||||||
$headers = [
|
$headers = [
|
||||||
'Authorization' => 'RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg',
|
'Authorization' => NOTIFICATION_SERVICE_KEY,
|
||||||
];
|
];
|
||||||
$body = new \stdClass();
|
$body = new \stdClass();
|
||||||
$body->agent_code = $agent_code;
|
$body->agent_code = $agent_code;
|
||||||
|
|
|
@ -5,6 +5,8 @@ define("DB_HOST", "localhost");
|
||||||
define("DB_USER", "root");
|
define("DB_USER", "root");
|
||||||
define("DB_PASSWORD", "vps@2017GA");
|
define("DB_PASSWORD", "vps@2017GA");
|
||||||
#define("DB_DATABASE","iLink_test2");
|
#define("DB_DATABASE","iLink_test2");
|
||||||
define("DB_DATABASE","iLink_cannary");
|
define("DB_DATABASE","iLink_preprod");
|
||||||
define("GEOLOCATED_AGENT_ETAT",0);
|
define("GEOLOCATED_AGENT_ETAT",0);
|
||||||
|
define("NOTIFICATION_SERVICE_URL",'localhost:8083');
|
||||||
|
define("NOTIFICATION_SERVICE_KEY",'RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg')
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue