Bug Fixes 7 : Forgot password : ps
This commit is contained in:
parent
3300e42a01
commit
e226cca142
@ -58,7 +58,8 @@
|
||||
|
|
||||
| $autoload['libraries'] = array('user_agent' => 'ua');
|
||||
*/
|
||||
$autoload['libraries'] = array('session','database','email');
|
||||
|
||||
$autoload['libraries'] = array('session','database','email','security');
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
@ -131,4 +132,7 @@
|
||||
|
|
||||
| $autoload['model'] = array('first_model' => 'first');
|
||||
*/
|
||||
$autoload['model'] = array('auth/auth_model');
|
||||
$autoload['model'] = array('auth/auth_model');
|
||||
// $autoload['model'] = array('Auth/Auth_model');
|
||||
// $autoload['model'] = array('auth_model' => 'auth/auth_model');
|
||||
// $autoload['model'] = array('auth_model' => 'Auth/Auth_model');
|
||||
@ -58,7 +58,7 @@
|
||||
|
|
||||
| $autoload['libraries'] = array('user_agent' => 'ua');
|
||||
*/
|
||||
$autoload['libraries'] = array('session','database','email');
|
||||
$autoload['libraries'] = array('session','database','email','security');
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
| a PHP script and you can easily do that on your own.
|
||||
|
|
||||
*/
|
||||
$base = "http://".$_SERVER['HTTP_HOST'];
|
||||
$base = "https://".$_SERVER['HTTP_HOST'];
|
||||
$base .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
|
||||
$config['base_url'] = $base;
|
||||
|
||||
|
||||
@ -58,7 +58,8 @@
|
||||
|
|
||||
| $autoload['libraries'] = array('user_agent' => 'ua');
|
||||
*/
|
||||
$autoload['libraries'] = array('session','database','email');
|
||||
|
||||
$autoload['libraries'] = array('session','database','email','security');
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
|
||||
@ -224,7 +224,7 @@
|
||||
| your log files will fill up very fast.
|
||||
|
|
||||
*/
|
||||
$config['log_threshold'] = 0;
|
||||
$config['log_threshold'] = 4;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@ -77,13 +77,12 @@ function send_emails($to, $subject, $body, $aliasName = '', $cc = null, $bcc = n
|
||||
|
||||
if (!function_exists('send_emails_forgot_password')) {
|
||||
|
||||
function send_emails_forgot_password($to, $subject, $body, $aliasName = '', $cc = null, $bcc = null, $receipt = null)
|
||||
function send_emails_forgot_password($to, $subject, $body, $mailCredentials = null, $aliasName = '', $cc = null, $bcc = null, $receipt = null)
|
||||
{
|
||||
|
||||
log_message('error', 'send_mail_helper_loadded');
|
||||
log_message('error', 'Receiptent mail - ' . $to . ' - subject - ' . $subject . ' - body - ' . $body);
|
||||
log_message('error', 'Sender mail ' . business()->sender_mail);
|
||||
|
||||
log_message('error', 'Sender mail ' . $mailCredentials->sender_mail);
|
||||
|
||||
try {
|
||||
$mailer = new PHPMailer(true);
|
||||
@ -91,14 +90,14 @@ function send_emails_forgot_password($to, $subject, $body, $aliasName = '', $cc
|
||||
|
||||
$mailer->isSMTP();
|
||||
$mailer->CharSet = 'utf-8';
|
||||
$mailer->Host = business()->mail_hostname;
|
||||
$mailer->SMTPSecure = business()->mail_security;
|
||||
$mailer->Host = $mailCredentials->mail_hostname;
|
||||
$mailer->SMTPSecure = $mailCredentials->mail_security;
|
||||
$mailer->SMTPAuth = true;
|
||||
$mailer->SMTPDebug = false;
|
||||
$mailer->Username = business()->mail_username;
|
||||
$mailer->Password = business()->mail_password;
|
||||
$mailer->Port = business()->mail_port_no;
|
||||
$mailer->setFrom(business()->sender_mail, $aliasName);
|
||||
$mailer->Username = $mailCredentials->mail_username;
|
||||
$mailer->Password = $mailCredentials->mail_password;
|
||||
$mailer->Port = $mailCredentials->mail_port_no;
|
||||
$mailer->setFrom($mailCredentials->sender_mail, $aliasName);
|
||||
$mailer->addAddress($to);
|
||||
|
||||
// Add CC recipients
|
||||
|
||||
@ -150,13 +150,15 @@ public function sendOTP(){
|
||||
$otp = $this->input->get('otp');
|
||||
$where = 'email';
|
||||
$user = $this->auth_model->validateUserForOtp($mail, $where);
|
||||
$mailCredentials = $this->auth_model->validateBusiness($user->business_id);
|
||||
|
||||
$id = $user->id;
|
||||
$data['csrf_hash'] = $this->security->get_csrf_hash();
|
||||
$data['id'] = $id;
|
||||
$data['email'] = $mail;
|
||||
|
||||
|
||||
$body =`
|
||||
$body = <<<EOD
|
||||
<body style="font-family: Arial, sans-serif;">
|
||||
|
||||
<div style="max-width: 600px; margin: 0 auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px;">
|
||||
@ -164,27 +166,27 @@ public function sendOTP(){
|
||||
<p>Hello,</p>
|
||||
<p>Your One-Time Password (OTP) for verification is:</p>
|
||||
<div style="text-align: center; background-color: #f5f5f5; padding: 10px; border-radius: 5px; font-size: 24px; margin-top: 15px;">
|
||||
<strong>`. $otp .`</strong>
|
||||
<strong>$otp</strong>
|
||||
</div>
|
||||
<p>This OTP is valid for a short period. Please do not share it with anyone.</p>
|
||||
<p>If you did not request this OTP, please ignore this email.</p>
|
||||
<p>Thank you!</p>
|
||||
<hr style="border: 1px solid #ccc; margin-top: 20px; margin-bottom: 20px;">
|
||||
<p style="text-align: center; color: #777;">© 2023 </p>
|
||||
|
||||
<p style="text-align: center; color: #777;">© 2023 $mailCredentials->business_name </p>
|
||||
</div>
|
||||
|
||||
</body>`;
|
||||
</body>
|
||||
EOD;
|
||||
|
||||
$subject = 'Forgot Password OTP Send';
|
||||
|
||||
$result = send_emails_forgot_password($mail, $subject, $body);
|
||||
$result = send_emails_forgot_password($mail, $subject, $body,$mailCredentials);
|
||||
|
||||
if($result){
|
||||
$data['csrf_hash'] = $this->security->get_csrf_hash();
|
||||
$data['status'] = "success";
|
||||
$data['id'] = $id;
|
||||
$data['email'] = $mail;
|
||||
$data['result'] = $result;
|
||||
echo json_encode($data);
|
||||
|
||||
}else{
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
<section class="login_content">
|
||||
<form id="otp-form" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo base_url();?>Auth/verify_otp" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="csrf_test_name" value="<?php echo $this->security->get_csrf_hash();?>">
|
||||
<input type="hidden" name="ci_csrf_token" value="<?php echo $this->security->get_csrf_hash();?>">
|
||||
<input type="hidden" id="hidden_otp" name="hidden_otp" class="form-control" value="" />
|
||||
<input type="hidden" id="id" name="id" value="">
|
||||
<input type="hidden" id="email1" name="email" value="">
|
||||
@ -149,7 +149,7 @@ function send_otp() {
|
||||
json: true,
|
||||
success: function(response) {
|
||||
response = jQuery.parseJSON(response)
|
||||
alert(response);
|
||||
// alert(response);
|
||||
if (response.status == "failed") {
|
||||
new PNotify({
|
||||
title: 'OTP Send Failed',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user