Merge branch 'master' of bitbucket.org:venbaittech/ams

This commit is contained in:
sriramv 2023-01-11 11:57:31 +05:30
commit 224dd918dc
6 changed files with 352 additions and 49 deletions

View File

@ -26,8 +26,10 @@ public function __construct()
// To inherit directly the attributes of the parent class.
parent::__construct();
$this->load->model('auth_model');
$this->load->model('MY_Model');
}
/**
* [index description]
*
@ -131,4 +133,65 @@ public function logout()
$this->auth_model->logout();
redirect('login');
}
public function lost_your_password()
{
$this->layout->load_view("auth/otp_verification");
}
public function send__mail(){
// otp generator
$otp = rand ( 1000 , 9999 );
$data['otp'] = $otp;
$mail = $this->input->post('email');
$user = $this->auth_model->validate_user();
if (empty($user)) {
$data['csrf_hash'] = $this->security->get_csrf_hash();
$data['status'] = "failed";
echo json_encode($data);
}
else{
// $to = "suseendhiran1999@gmail.com"; // $mail
// $subject = "OTP";
// $message = $otp;
// $success_msg = $this->auth_model->send_email($to, $subject, $message);
$data['csrf_hash'] = $this->security->get_csrf_hash();
$data['status'] = "success";
$data['id'] = $user->id;
echo json_encode($data);
}
}
public function verify_otp(){
$generate_otp = $this->input->post('hidden_otp');
$user_entered_otp = $this->input->post('otp');
$id = $this->input->post('id');
if ($generate_otp == $user_entered_otp)
{
$data['generate_otp'] = $generate_otp;
$data['user_entered_otp'] = $user_entered_otp;
$data['csrf_hash'] = $this->security->get_csrf_hash();
$data['status'] = "success";
$data['id'] = $id;
$htmlPage = $this->load->view('change_password_form.php',$data,true);
$data['htmlPage'] = $htmlPage;
echo json_encode($data);
}
else
{
$data['csrf_hash'] = $this->security->get_csrf_hash();
$data['status'] = "failed";
echo json_encode($data);
}
}
public function change_password()
{
$id = $this->input->post('id');
$data['password'] = hash_password($this->input->post('password'));
$table="users";
$userData = $this->MY_Model->edit_option($data, $id, $table);
redirect('login');
}
}

View File

@ -0,0 +1,102 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AMS </title>
<!-- Bootstrap -->
<link href="<?php echo base_url(); ?>/assets/default/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="<?php echo base_url(); ?>/assets/default/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<!-- NProgress -->
<link href="<?php echo base_url(); ?>/assets/default/nprogress/nprogress.css" rel="stylesheet">
<!-- Animate.css -->
<link href="<?php echo base_url(); ?>/assets/default/animate.css/animate.min.css" rel="stylesheet">
<!-- Custom Theme Style -->
<link href="<?php echo base_url(); ?>/assets/default/build/css/custom.min.css" rel="stylesheet">
</head>
<style>
.field-icon {
float: right;
margin-left: -25px;
margin-top: -45px;
margin-right: 10px;
position: relative;
z-index: 3;
}
</style>
<body class="login">
<div class="login_wrapper">
<div class="animate form login_form">
<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/change_password" enctype="multipart/form-data">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
<input type="hidden" id="id" name="id" value="<?php echo $id ?>">
<h1>Forgot Password</h1>
<div>
<input type="password" id="password" name="password" class="form-control" placeholder="Password" required="required" />
<span toggle="#password" id="toggle-password" class="fa fa-fw fa-eye field-icon toggle-password"></span>
</div>
<div>
<input type="password" id="confirm_password" name="confirm_password" class="form-control" placeholder="Confrim Password" required="required" />
<p id='message'></p>
</div>
<div>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
<div class="clearfix"></div>
<!-- <div class="separator">
<p class="change_link">Already a member ?
<a href="<?php echo base_url().'auth/verify_user'?>" class="to_register"> Log in </a>
</p>
<div class="clearfix"></div>
<br />
<div>
<h1><i class="fa fa-paw"></i> Gentelella Alela!</h1>
<p>©2016 All Rights Reserved. Gentelella Alela! is a Bootstrap 4 template. Privacy and Terms</p>
</div>
</div> -->
</form>
</section>
<script>
$("#toggle-password").click(function() {
$(this).toggleClass("fa-eye fa-eye-slash");
var input = $($(this).attr("toggle"));
if (input.attr("type") == "password") {
input.attr("type", "text");
}
else {
input.attr("type", "password");
}
});
$('#password, #confirm_password').on('keyup', function () {
$(':input[type="submit"]').prop('disabled', true);
if ($('#password').val() == $('#confirm_password').val() && $('#confirm_password').val().length > 0 ) {
$('#message').html('Matching').css('color', 'green');
$('button[type="submit"]').attr("disabled", false);
}
else if($('#password').val().length == 0 || $('#confirm_password').val().length == 0){
$('#message').html('');
}
else
$('#message').html('Not Matching').css('color', 'red');
});
</script>
</div>
</div>
</body>
</html>

View File

@ -39,25 +39,19 @@
</div>
<div>
<input type="password" class="form-control" value="password" name="password" placeholder="Password" required="" />
<?php
if ( $this->session->flashdata('msg')) {
?>
<p id='message' style="color:red"><?php echo $this->session->flashdata('msg'); ?></p>
<?php
}
?>
<p id='message' style="color:red"><?php echo $this->session->flashdata('msg'); ?></p>
</div>
<div>
<button type="submit" class="btn btn-primary">Log in</button>
<!-- <a class="reset_pass" href="#">Lost your password?</a> -->
<a class="reset_pass" href="<?php echo base_url();?>auth/lost_your_password">Lost your password?</a>
</div>
<div class="clearfix"></div>
<div class="separator">
<!-- <p class="change_link">New to site?
<a href="#signup" class="to_register"> Create Account </a>
</p> -->
<!-- <p class="change_link">New to site? -->
<a href="<?php echo base_url().'auth/lost_your_password'?>" class="to_register"> Create Account </a>
</p>
<div class="clearfix"></div>
<br />
@ -82,7 +76,6 @@
<input type="email" class="form-control" placeholder="Email" required="" />
</div>
<div>
<input type="password" class="form-control" placeholder="Password" required="" />
</div>
<div>
@ -100,13 +93,15 @@
<br />
<div>
<h1>Venba Infotech!</h1>
<p>©2016 All Rights Reserved. Venba Infotech! is a Bootstrap 4 template. Privacy and Terms</p>
<h1><i class="fa fa-paw"></i> Gentelella Alela!</h1>
<p>©2016 All Rights Reserved. Gentelella Alela! is a Bootstrap 4 template. Privacy and Terms</p>
</div>
</div>
</form>
</section>
</div>
</div>
</div>

View File

@ -0,0 +1,174 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AMS </title>
<!-- Bootstrap -->
<link href="<?php echo base_url(); ?>/assets/default/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="<?php echo base_url(); ?>/assets/default/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<!-- NProgress -->
<link href="<?php echo base_url(); ?>/assets/default/nprogress/nprogress.css" rel="stylesheet">
<!-- Animate.css -->
<link href="<?php echo base_url(); ?>/assets/default/animate.css/animate.min.css" rel="stylesheet">
<!-- Custom Theme Style -->
<link href="<?php echo base_url(); ?>/assets/default/build/css/custom.min.css" rel="stylesheet">
</head>
<style>
.otp{
text-align: right;
clear: both;
float:right;
}
</style>
<body class="login">
<div class="login_wrapper">
<div class="animate form login_form">
<section class="login_content">
<form id="otp-form" data-parsley-validate class="form-horizontal form-label-left" method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" 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="">
<h1>Forgot Password</h1>
<!-- <div>
<input type="text" class="form-control" placeholder="Username" required="" />
</div> -->
<div>
<a href="#" onclick="send_otp()" class="otp"> Send OTP </a>
<div>
<input type="email" id="email" name="user_name" class="form-control" placeholder="Email" required="required" />
<p id="span_msg"></p>
</div>
</div>
<div>
<input type="text" id="otp" name="otp" class="form-control" placeholder="OTP" required="required" />
<p id="otp_span_msg"></p>
</div>
<div>
<button type="button" class="btn btn-primary">Submit</button>
<!-- Button trigger modal -->
<!-- <button type="button" class="btn btn-secondary" data-toggle="modal" data-target=".bs-example-modal-sm">
Small modal
</button> -->
</div>
<div class="clearfix"></div>
<div class="separator">
<p class="change_link">Already a member ?
<a href="<?php echo base_url().'auth/verify_user'?>" class="to_register"> Log in </a>
</p>
<div class="clearfix"></div>
<br />
<div>
<h1><i class="fa fa-paw"></i> Gentelella Alela!</h1>
<p>©2016 All Rights Reserved. Gentelella Alela! is a Bootstrap 4 template. Privacy and Terms</p>
</div>
</div>
</form>
</section>
</div>
</div>
<div class="body"></div>
<script>
function send_otp(){
if ($('#email').val())
{
$('#span_msg').html('');
var data = $("#otp-form").serialize();
$.ajax({
type: "post",
url: "<?php echo base_url();?>auth/send__mail",
data: data,
json: true,
success: function (response) {
// decode encoded json
response = jQuery.parseJSON(response)
if (response.status == "failed") {
//update the csrf to the form
$('input[name=csrf_test_name]').val(response.csrf_hash);
$('#span_msg').html('invalid username').css('color', 'red');
}
else{
//update the csrf to the form
$('input[name=csrf_test_name]').val(response.csrf_hash);
$('#hidden_otp').val(response.otp);
$('#id').val(response.id);
console.log(response.otp);
console.log(response.id);
}
},
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
});
}
else
{
$('#span_msg').html('Enter Email').css('color', 'red');
}
}
$('#email').on('keyup', function () {
if (!$('#email').val())
$('#span_msg').html('');
});
$('#otp').on('keyup', function () {
if (!$('#otp').val())
$('#otp_span_msg').html('');
});
$(document).on('click','#close-form',function(){
$('.bs-example-modal-sm').css('display', 'none');
});
$(document).on('click','.btn-primary',function(){
if ($('#otp').val()){
var data = $("#otp-form").serialize();
console.log(data);
$.ajax({
type: "post",
url: "<?php echo base_url();?>auth/verify_otp",
data: data,
json: true,
success: function(response) {
// decode encoded json
response = jQuery.parseJSON(response)
if (response.status === "failed") {
//update the csrf to the form
$('input[name=csrf_test_name]').val(response.csrf_hash);
$('#otp_span_msg').html('invalid otp').css('color', 'red');
}
else {
//update the csrf to the form
$('input[name=csrf_test_name]').val(response.csrf_hash);
console.log(response.id);
$('.form').html(response.htmlPage);
// location.href = `<?php echo base_url();?>auth/change_password_view/${response.id}`;
}
},
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
});
}
else{
$('#otp_span_msg').html('Pls enter OTP').css('color', 'red');
}
});
</script>
</body>
</html>

View File

@ -195,39 +195,4 @@ public function businessProfile($business_id)
$this->layout->render('default_layout');
}
// public function editprofile($id)
// {
// $usertData = $this->user_model->get_user_by_md5_id($id,user()->business_id);
// $this->layout->set('editData', $usertData);
// $this->layout->buffer('main_content', 'User/edit_profile');
// $this->layout->render('default_layout');
// }
// public function editprofiles()
// {
// $table="users";
// $action = $this->input->post();
// $id = $this->input->post('id');
// //file upload confic
// $user_image['upload_path'] = APPPATH. '../assets/uploads/profile_picture';
// $user_image['allowed_types'] = 'jpg|png';
// $user_image['max_size'] = 80000;
// //upload
// $this->load->library('upload', $user_image);
// $this->upload->initialize($user_image);
// if ( ! $this->upload->do_upload('profile_image'))
// {
// $error = array('error' => $this->upload->display_errors());
// unset($action['profile_image']);
// } else{
// $upload_user_image = $this->upload->data();
// $action['profile_image'] = $upload_user_image['file_name'];
// }
// $userData = $this->MY_Model->edit_option($action, $id, $table);
// redirect('user/profile');
// }
}

View File

@ -240,6 +240,10 @@ $("#file_profile").change(function(){
});
});