- Add complete Auth module with login, logout, lock screen functionality - Fix 401 error on error monitoring page by adding /error-monitoring/ to public patterns - Improve lock screen with proper form handling and unlock functionality - Add RoleModel and role management views - Add BaseModel for common model functionality - Update authentication system and middleware - Add troubleshooting documentation - Update assets and build tools
178 lines
8.1 KiB
PHP
178 lines
8.1 KiB
PHP
<?php
|
|
use App\Core\View;
|
|
?>
|
|
<div class="auth-page-wrapper" style="min-height: 100vh; display: flex; flex-direction: column;">
|
|
<!-- auth page bg -->
|
|
<div class="auth-one-bg-position auth-one-bg" id="auth-particles" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1;">
|
|
<div class="bg-overlay"></div>
|
|
|
|
<div class="shape">
|
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1440 120">
|
|
<path d="M 0,36 C 144,53.6 432,123.2 720,124 C 1008,124.8 1296,56.8 1440,40L1440 140L0 140z"></path>
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- auth page content -->
|
|
<div class="auth-page-content" style="flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px 0;">
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-12 text-center mb-4">
|
|
<div class="text-white-50">
|
|
<div>
|
|
<a href="/index/" class="d-inline-block auth-logo">
|
|
<img src="<?php echo \App\Core\AppConfig::getLogoLight(); ?>" alt="" height="20">
|
|
</a>
|
|
</div>
|
|
<p class="mt-3 fs-15 fw-medium">BitReport CRM - Sistema de Gestão Empresarial</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end row -->
|
|
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8 col-lg-6 col-xl-5">
|
|
<div class="card">
|
|
|
|
<div class="card-body p-4">
|
|
<div class="text-center mt-2">
|
|
<h5 class="text-primary">Lock Screen</h5>
|
|
<p class="text-muted">Enter your password to unlock the screen!</p>
|
|
</div>
|
|
<div class="user-thumb text-center">
|
|
<img src="<?php echo View::asset('/assets/images/users/avatar-1.jpg'); ?>" class="rounded-circle img-thumbnail avatar-lg" alt="thumbnail">
|
|
<h5 class="font-size-15 mt-3">Pedro Alves</h5>
|
|
</div>
|
|
<div class="p-2 mt-4">
|
|
<form id="lockScreenForm" method="POST" action="/auth/unlock">
|
|
<div class="mb-3">
|
|
<label class="form-label" for="userpassword">Password</label>
|
|
<input type="password" class="form-control" id="userpassword" name="password" placeholder="Enter password" required>
|
|
</div>
|
|
<div class="mb-2 mt-4">
|
|
<button class="btn btn-success w-100" type="submit" id="unlockBtn">
|
|
<span class="spinner-border spinner-border-sm d-none" role="status" aria-hidden="true"></span>
|
|
<span class="btn-text">Unlock</span>
|
|
</button>
|
|
</div>
|
|
</form><!-- end form -->
|
|
|
|
</div>
|
|
</div>
|
|
<!-- end card body -->
|
|
</div>
|
|
<!-- end card -->
|
|
|
|
<div class="mt-4 text-center">
|
|
<p class="mb-0">Not you ? return <a href="/login" class="fw-semibold text-primary text-decoration-underline"> Signin </a> </p>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<!-- end row -->
|
|
</div>
|
|
<!-- end container -->
|
|
</div>
|
|
<!-- end auth page content -->
|
|
|
|
<!-- footer -->
|
|
<footer class="footer">
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
<div class="text-center">
|
|
<p class="mb-0 text-muted">©
|
|
<script>document.write(new Date().getFullYear())</script> <?php echo \App\Core\AppConfig::getCompanyName(); ?>.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
<!-- end Footer -->
|
|
</div>
|
|
<!-- end auth-page-wrapper -->
|
|
|
|
<!-- particles js -->
|
|
|
|
<!-- particles app js -->
|
|
<script src="<?php echo View::asset('/assets/libs/particles.js/particles.js'); ?>"></script>
|
|
<script src="<?php echo View::asset('/assets/js/pages/particles.app.js'); ?>"></script>
|
|
|
|
<!-- Lock Screen Form Handler -->
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const form = document.getElementById('lockScreenForm');
|
|
const unlockBtn = document.getElementById('unlockBtn');
|
|
const spinner = unlockBtn.querySelector('.spinner-border');
|
|
const btnText = unlockBtn.querySelector('.btn-text');
|
|
|
|
form.addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
// Show loading state
|
|
unlockBtn.disabled = true;
|
|
spinner.classList.remove('d-none');
|
|
btnText.textContent = 'Unlocking...';
|
|
|
|
try {
|
|
const formData = new FormData(form);
|
|
const response = await fetch('/auth/unlock', {
|
|
method: 'POST',
|
|
body: formData,
|
|
headers: {
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
}
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
// Redirect to dashboard
|
|
window.location.href = '/dashboard';
|
|
} else {
|
|
// Check if we need to redirect to login
|
|
if (result.redirect) {
|
|
window.location.href = result.redirect;
|
|
return;
|
|
}
|
|
// Show error message
|
|
showAlert('error', result.message || 'Invalid password. Please try again.');
|
|
}
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
if (error.name === 'TypeError' && error.message.includes('fetch')) {
|
|
showAlert('error', 'Network error. Please check your connection and try again.');
|
|
} else {
|
|
showAlert('error', 'An error occurred. Please try again.');
|
|
}
|
|
} finally {
|
|
// Reset button state
|
|
unlockBtn.disabled = false;
|
|
spinner.classList.add('d-none');
|
|
btnText.textContent = 'Unlock';
|
|
}
|
|
});
|
|
|
|
function showAlert(type, message) {
|
|
// Create alert element
|
|
const alertDiv = document.createElement('div');
|
|
alertDiv.className = `alert alert-${type === 'error' ? 'danger' : 'success'} alert-dismissible fade show`;
|
|
alertDiv.innerHTML = `
|
|
${message}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
`;
|
|
|
|
// Insert before form
|
|
form.parentNode.insertBefore(alertDiv, form);
|
|
|
|
// Auto remove after 5 seconds
|
|
setTimeout(() => {
|
|
if (alertDiv.parentNode) {
|
|
alertDiv.remove();
|
|
}
|
|
}, 5000);
|
|
}
|
|
});
|
|
</script>
|