In my table the password is in encrypted form. i used MD5 to encrypt password.now i want to send password if emailid is present in database. everything is working correctly...but the password is sending in encrypted form in email to user.
how i decrypt this before sending email and send original password to useron email.
below is my code..
function forgotpassword() {
$this->layout = "layout_login";
if (!empty($this->request->data)) {
$email = $this->request->data['User']['email'];
if (!empty($email)) {
$user = $this->User->find('first', array(
'conditions' => array(
'User.email' => $this->request->data['User']['email'],
'User.status' => 1
)
));
if(!$user) {
$this->Session->setFlash("No Such E-mail address registerd with us");
} else {
$subject = "Account Password from Kaya Dispatch";
$this->Email->from = 'luckybajpai87@gmail.com';
$to = trim($this->request->data['User']['email']);
$this->Email->sendAs = 'both';
$this->Email->to = $to;
$this->Email->subject = $subject;
$email = $user['User']['email'];
$password = md5($user['User']['password']);
$message = "";
$message .= "Please find the below Email ID and Password of your account: <br/><br/>";
$message .= "<b>Your Email:</b> " .$email. "<br/>";
$message .= "<b>Your Password:</b> " . $password . "<br/>";
$message .= "<br/>Thanks, <br/>Support Team";
if ($this->Email->send($message)) {
$this->Session->setFlash("Password Send Successfully to your email");
} else {
$this->Session->setFlash("Something Went Wrong.Email is not send");
}
}
}
}
}