forgot password : ps

This commit is contained in:
VE10-Sanjeev 2024-03-23 11:21:59 +05:30
parent 42d4f3e6a3
commit 54a0c9717c

View File

@ -52,11 +52,13 @@
<form action="<?= base_url() . "authenticate" ?>" method="post">
<div class="form-group mb-3">
<label for="emailaddress">Email address</label>
<input class="form-control" type="email" name="username" id="emailaddress" placeholder="Enter your email" autocomplete="off"required>
<input class="form-control" type="email" name="username" id="emailaddress" required placeholder="Enter your email" autocomplete="off">
<div class="invalid-feedback"> Please enter the email id</div>
</div>
<div class="form-group mb-3">
<!-- <a href="auth-recoverpw-2.html" class="text-muted float-right"><small>Forgot your password?</small></a> -->
<!-- <a href="<?= base_url()."auth_confirm_mail"; ?>" class="text-muted float-right"><small>Forgot your password?</small></a> -->
<a href="#" id="resetLink" class="text-muted float-right"><small>Forgot your password?</small></a>
<label for="password">Password</label>
<div class="input-group input-group-merge">
@ -78,9 +80,7 @@
<?php if (isset($validationErrors)) : ?>
<span class="widget-simple text-center">
<div class="media-body align-self-center font-24 avatar-title">
<small class="mt-3" style="color: black; font-size:18px;"><?= $validationErrors; ?></small>
<small class="mb-2" style="color: black; font-size:18px;"><?= $validationErrors; ?></small>
</div>
</span>
<?php endif; ?>
@ -121,28 +121,48 @@
<script src="<?= base_url() . "public/assets/js/app.min.js" ?>"></script>
<script>
$(document).ready(function() {
// Fetch email value and set it as href for the reset link
$('#emailaddress').on('input', function() {
var emailValue = $(this).val();
var baseUrl = "<?php echo base_url(); ?>";
$('#resetLink').attr('href', emailValue ? baseUrl+'auth_confirm_mail?email='+emailValue : '#');
});
$(document).ready(function() {
// Fetch email value and set it as href for the reset link
// $('#emailaddress').on('input', function() {
// var emailValue = $(this).val();
// var baseUrl = "<?php echo base_url(); ?>";
// $('#resetLink').attr('href', emailValue ? baseUrl+'auth_confirm_mail?email='+emailValue : '#');
// // $('#resetLink').attr('href', 'auth_confirm_mail?email='+emailValue);
// });
$('#resetLink').on('click', function(event) {
var emailValue = $('#emailaddress').val();
var baseUrl = "<?php echo base_url(); ?>";
if (!emailValue) {
event.preventDefault();
console.log('Please enter your email before clicking on "Forgot your password?"');
alert('Please enter your email before clicking on "Forgot your password?"');
} else {
$.ajax({
type: "POST",
url: "<?= base_url() . 'auth_confirm_mail' ?>",
data: { email: emailValue },
success: function(response) {
console.log(response);
if (response['data']['status']) {
alert(response['data']['message']);
$('#emailaddress').val('');
console.log("Email confirmation successful");
} else {
alert(response['data']['message']);
console.log(response['data']['message']);
}
},
error: function(error) {
console.log('AJAX Error:', error.responseText);
// Handle error here, if needed
}
});
// Check if email is entered before clicking on forgot password link
// $('#resetLink').on('click', function(event) {
// if (!$('#emailaddress').val()) {
// event.preventDefault();
// console.log('Please enter your email before clicking on "Forgot your password?"');
// alert('Please enter your email before clicking on "Forgot your password?"');
// } else {
// console.log('Proceeding to password reset link for email:', $('#emailaddress').val());
// $('#resetLink').attr('href', 'auth_confirm_mail?email=' + $('#emailaddress').val());
// }
// });
});
}
});
});
</script>
</body>
</html>
</html>