From b4b714cc5d4076499f7e4c9c020830a0630a7f01 Mon Sep 17 00:00:00 2001 From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com> Date: Fri, 12 May 2023 14:33:32 +0530 Subject: [PATCH] template mail:suseendhiran --- app/Config/Routes.php | 2 + app/Controllers/Admin_controller.php | 29 ++++++ app/Controllers/Sendmail_controller.php | 19 ++-- app/Views/admin_login.php | 4 +- app/Views/forgot_password.php | 22 +++- app/Views/layout/header.php | 4 +- app/Views/member_form.php | 2 +- app/Views/member_login.php | 2 +- app/Views/profile.php | 7 +- app/Views/user_form.php | 2 +- app/Views/users_password.php | 3 +- app/Views/verification_mail_temp.php | 131 ++++++++++++++++++++++++ 12 files changed, 205 insertions(+), 22 deletions(-) create mode 100644 app/Views/verification_mail_temp.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2bb83d5..3ac43eb 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -70,6 +70,8 @@ $routes->match(['get','post'],'/credits_pack_add','Admin_controller::credits_pac $routes->match(['get','post'],'/user_password_change','Admin_controller::user_password_change'); $routes->match(['get','post'],'/user_deactivate/(:any)','Admin_controller::user_deactivate/$1'); $routes->match(['get','post'],'/user_activate/(:any)','Admin_controller::user_activate/$1'); +$routes->match(['get','post'],'/user_forgot_password','Admin_controller::user_forgot_password'); + $routes->match(['get'],'/admin_home','Dashboard::admin_home'); $routes->match(['get'],'/member_home','Dashboard::member_home'); diff --git a/app/Controllers/Admin_controller.php b/app/Controllers/Admin_controller.php index 001a426..c326dcb 100644 --- a/app/Controllers/Admin_controller.php +++ b/app/Controllers/Admin_controller.php @@ -300,5 +300,34 @@ class Admin_controller extends BaseController echo view('layout/footer'); } + + public function user_forgot_password() + { + if($this->request->getmethod() == 'get') + { + $this->session->setTempdata('user',"user",3); + return view('forgot_password.php'); + } + else if($this->request->getmethod() == 'post') + { + + $email = $this->request->getVar('email'); + $user_data = $this->UserModel->where('email', $email)->find(); + if ($user_data) + { + $otp = rand(1000 , 9999); + $this->index($this->request->getVar('email') , $otp , 2 ); + $data['status'] = 'success'; + $data['otp'] = $otp; + echo json_encode($data); + } + else + { + $data['status'] = 'failed'; + echo json_encode($data); + } + + } + } // ----------------------------------------------- } diff --git a/app/Controllers/Sendmail_controller.php b/app/Controllers/Sendmail_controller.php index a1f73d5..9deba3e 100644 --- a/app/Controllers/Sendmail_controller.php +++ b/app/Controllers/Sendmail_controller.php @@ -19,18 +19,24 @@ class Sendmail_controller extends BaseController $email->setTo($to); if ($return == 2) { - $message = $code; + $data['id'] = '2'; + $data['otp'] = $code; + $message = view('verification_mail_temp',$data); } if($return == 3) { - $message = "

username : $to

"; - $message .= "

password : $code

"; - $message .= '

Login here

'; + $data['id'] = '3'; + $data['username'] = $to; + $data['password'] = $code; + $data['url'] = base_url()."admin"; + $message = view('verification_mail_temp',$data); } else { - $message = '

Please click the following link to verify your email address

'; - $message .= '

Verify Email

'; + $data['to'] = $to; + $data['code'] = $code; + $data['url'] = base_url()."/verify_email/".md5($code); + $message = view('verification_mail_temp',$data); } $email->setSubject('Verify your email address'); $email->setMessage($message); @@ -85,6 +91,7 @@ class Sendmail_controller extends BaseController public function forgot_password() { + $this->session->setTempdata('user',"member",3); if($this->request->getmethod() == 'get') { return view('forgot_password.php'); diff --git a/app/Views/admin_login.php b/app/Views/admin_login.php index 2cf9476..95f7aeb 100644 --- a/app/Views/admin_login.php +++ b/app/Views/admin_login.php @@ -87,7 +87,7 @@
-

Forgot your password?

+

" class="">Forgot your password?

@@ -102,7 +102,7 @@ diff --git a/app/Views/forgot_password.php b/app/Views/forgot_password.php index 19d89fd..771b978 100644 --- a/app/Views/forgot_password.php +++ b/app/Views/forgot_password.php @@ -46,6 +46,7 @@
+
@@ -90,7 +91,7 @@ @@ -109,16 +110,22 @@ $('#alert').delay(3000).fadeOut('slow'); $(".disable").hide(); $(document).on('click','#submit1',function(){ + $('#alert1').html('Please wait...'); var email = $("#email").val(); + var url; + var user_role = $('#user').val(); + if ($('#user').val() == 'member') { url = "forgot_password" } + else { url = "user_forgot_password" } $.ajax({ type: "post", - url: "forgot_password", + url: url, data: { email : email }, json: true, success: function(response) { response = jQuery.parseJSON(response); if (response.status == "success") { + $('#alert1').html(''); $(".disable").show(); $('#verify_otp').val(response.otp); $("#re-sub").html(''); @@ -126,8 +133,17 @@ $(document).on('click','#submit1',function(){ } else { + console.log(user_role); + $('#alert1').html(''); $('#alert1').addClass('alert alert-danger'); - $('#alert1').html('Email is not verified.please check your mail.') + if (user_role == 'member') + { + $('#alert1').html('Email is not verified.please check your mail.'); + } + else + { + $('#alert1').html('Invalid email.'); + } } diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 81cb8b0..4976650 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -288,10 +288,10 @@ $(document).ready(function(){ diff --git a/app/Views/profile.php b/app/Views/profile.php index 4cbebb5..7ce2374 100644 --- a/app/Views/profile.php +++ b/app/Views/profile.php @@ -80,7 +80,7 @@ body {
profile-image - +
Edit Profile @@ -91,7 +91,7 @@ body {
' class="rounded-circle avatar-xl img-thumbnail" alt="profile-image"> - +
Edit Profile @@ -131,13 +131,10 @@ body {