Files
verifikator/resources/views/auth/login.blade.php
T
2026-08-07 10:47:09 +07:00

796 lines
25 KiB
PHP

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>Login | {{ config('app.name') }}</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/simple-notify/dist/simple-notify.css" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap"
rel="stylesheet">
<style>
body {
background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #1d4ed8 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-family: "Inter", sans-serif;
padding: 20px;
}
.login-wrapper {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border-radius: 20px;
box-shadow: 0 20px 40px rgba(30, 58, 138, 0.3);
overflow: hidden;
width: 100%;
max-width: 1000px;
transition: transform 0.3s ease;
border: 1px solid rgba(59, 130, 246, 0.1);
display: flex;
min-height: 600px;
}
.login-wrapper:hover {
transform: translateY(-5px);
box-shadow: 0 25px 50px rgba(30, 58, 138, 0.4);
}
/* Image Section */
.image-section {
flex: 1;
background: linear-gradient(45deg, #1e3a8a 0%, #3b82f6 50%, #1d4ed8 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px;
color: white;
position: relative;
overflow: hidden;
}
.image-section::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><pattern id="grid" width="50" height="50" patternUnits="userSpaceOnUse"><path d="M 50 0 L 0 0 0 50" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100%" height="100%" fill="url(%23grid)"/></svg>');
opacity: 0.3;
}
.image-content {
position: relative;
z-index: 2;
text-align: center;
}
.image-content .icon {
font-size: 5rem;
margin-bottom: 30px;
background: rgba(255, 255, 255, 0.2);
width: 120px;
height: 120px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 30px;
backdrop-filter: blur(10px);
border: 2px solid rgba(255, 255, 255, 0.3);
}
.image-content h1 {
font-size: 2.5rem;
font-weight: 700;
margin-bottom: 20px;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.image-content p {
font-size: 1.1rem;
opacity: 0.9;
line-height: 1.6;
max-width: 300px;
margin: 0 auto;
}
.floating-elements {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: hidden;
z-index: 1;
}
.floating-elements::before,
.floating-elements::after {
content: '';
position: absolute;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
animation: float 6s ease-in-out infinite;
}
.floating-elements::before {
width: 200px;
height: 200px;
top: 10%;
right: -50px;
animation-delay: 0s;
}
.floating-elements::after {
width: 150px;
height: 150px;
bottom: 20%;
left: -30px;
animation-delay: 3s;
}
@keyframes float {
0%,
100% {
transform: translateY(0px);
}
50% {
transform: translateY(-20px);
}
}
/* Form Section */
.form-section {
flex: 1;
padding: 50px 40px;
display: flex;
flex-direction: column;
justify-content: center;
}
.login-header {
text-align: center;
margin-bottom: 30px;
}
.login-header h2 {
color: #1e3a8a;
font-weight: 600;
margin-bottom: 10px;
font-size: 2rem;
}
.login-header p {
color: #3b82f6;
font-size: 14px;
margin-bottom: 0;
}
.form-floating {
position: relative;
margin-bottom: 20px;
}
.form-floating input {
border: 2px solid #dbeafe;
border-radius: 12px;
padding: 15px 20px;
transition: all 0.3s ease;
background: #fafbfc;
}
.form-floating input:focus {
border-color: #3b82f6;
box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
transform: scale(1.02);
background: white;
}
.form-floating label {
color: #60a5fa;
font-size: 14px;
}
.btn-login {
background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #1d4ed8 100%);
border: none;
border-radius: 12px;
padding: 15px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.btn-login:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #1e40af 100%);
}
.btn-login:active {
transform: translateY(0);
}
.divider {
text-align: center;
margin: 25px 0;
position: relative;
}
.divider::before {
content: '';
position: absolute;
top: 50%;
left: 0;
right: 0;
height: 1px;
background: #dbeafe;
}
.divider span {
background: rgba(255, 255, 255, 0.95);
padding: 0 15px;
color: #60a5fa;
font-size: 14px;
}
.social-login {
display: flex;
gap: 10px;
}
.btn-social {
flex: 1;
padding: 12px;
border: 2px solid #dbeafe;
border-radius: 12px;
background: white;
transition: all 0.3s ease;
color: #3b82f6;
}
.btn-social:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(59, 130, 246, 0.2);
border-color: #3b82f6;
background: #f0f9ff;
}
.password-toggle {
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
color: #60a5fa;
z-index: 10;
}
.password-toggle:hover {
color: #3b82f6;
}
.input-error {
border-color: #dc3545 !important;
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}
/* Responsive Design */
@media (max-width: 992px) {
.login-wrapper {
max-width: 800px;
}
.image-content h1 {
font-size: 2rem;
}
.image-content .icon {
font-size: 4rem;
width: 100px;
height: 100px;
}
}
@media (max-width: 768px) {
body {
padding: 10px;
}
.login-wrapper {
flex-direction: column;
max-width: 500px;
min-height: auto;
}
.image-section {
padding: 30px 20px;
min-height: 250px;
}
.image-content h1 {
font-size: 1.8rem;
}
.image-content .icon {
font-size: 3rem;
width: 80px;
height: 80px;
margin-bottom: 20px;
}
.image-content p {
font-size: 1rem;
}
.form-section {
padding: 30px 25px;
}
.login-header h2 {
font-size: 1.5rem;
}
}
@media (max-width: 480px) {
.login-wrapper {
max-width: 100%;
}
.image-section {
padding: 25px 15px;
min-height: 200px;
}
.form-section {
padding: 25px 20px;
}
.image-content h1 {
font-size: 1.5rem;
}
.login-header h2 {
font-size: 1.3rem;
}
}
/* Loading Animation */
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.fa-spinner {
animation: spin 1s linear infinite;
}
</style>
</head>
<body>
<div class="login-wrapper">
<!-- Image Section -->
<div class="image-section">
<div class="floating-elements"></div>
<div class="image-content">
<div class="icon">
{{-- <i class="fas fa-shield-alt"></i> --}}
<img src="{{ asset('assets/images/logo-untan.png') }}" alt="untan.png" height="80">
</div>
<h1>Verifikator</h1>
<p>Sistem Verifikasi Remunerasi Universitas Tanjungpura</p>
</div>
</div>
<!-- Form Section -->
<div class="form-section">
<div class="login-header">
<h2>Selamat Datang</h2>
<p>Silakan masuk ke akun Anda untuk melanjutkan</p>
</div>
<form id="loginForm">
<div class="form-floating">
<input type="text" class="form-control" id="username" placeholder="Masukkan NIP"
name="username">
<label for="username"><i class="fas fa-user"></i> NIP</label>
</div>
<div class="form-floating position-relative">
<input type="password" class="form-control" id="password" placeholder="Masukkan Password"
name="password">
<label for="password"><i class="fas fa-lock"></i> Password</label>
<span class="password-toggle" onclick="togglePassword()">
<i class="fas fa-eye" id="eyeIcon"></i>
</span>
</div>
<!-- Slider Captcha -->
<div id="slider-captcha-container" style="margin-bottom: 20px; width: 100%;"></div>
<button type="submit" class="btn btn-login btn-primary w-100" id="loginButton">
<i class="fas fa-sign-in-alt"></i> Masuk
</button>
</form>
<div class="divider">
<span>atau</span>
</div>
<div class="social-login">
<button type="button" class="btn btn-social btn-google" onclick="loginWithGoogle()">
<i class="fab fa-google"></i> Google
</button>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<!-- JS -->
<script src="https://cdn.jsdelivr.net/npm/simple-notify/dist/simple-notify.min.js"></script>
<!-- Slider Captcha -->
<script src="{{ asset('assets/js/slider-captcha.js') }}?v={{ time() }}"></script>
<script>
// Fungsi notifikasi dinamis
function showNotification(options = {}) {
const defaultOptions = {
status: 'info',
title: 'Notification',
text: 'Default notification message',
effect: 'fade',
speed: 300,
customClass: null,
customIcon: null,
showIcon: true,
showCloseButton: true,
autoclose: true,
autotimeout: 3000,
gap: 20,
distance: 20,
type: 'outline',
position: 'right top'
};
const config = {
...defaultOptions,
...options
};
new Notify(config);
}
// Fungsi khusus untuk notifikasi sukses
function showSuccess(title = 'Success', text = 'Operation completed successfully') {
showNotification({
status: 'success',
title: title,
text: text,
});
}
// Fungsi khusus untuk notifikasi error
function showError(title = 'Error', text = 'An error occurred') {
showNotification({
status: 'error',
title: title,
text: text,
autotimeout: 5000
});
}
// Fungsi khusus untuk notifikasi warning
function showWarning(title = 'Warning', text = 'Please check your input') {
showNotification({
status: 'warning',
title: title,
text: text,
});
}
// Fungsi khusus untuk notifikasi info
function showInfo(title = 'Information', text = 'Here is some information') {
showNotification({
status: 'info',
title: title,
text: text,
});
}
// Fungsi untuk menangani error dari jQuery AJAX
function handleAjaxError(xhr, status, error) {
let errorMessage = 'An unexpected error occurred';
let errorTitle = 'Error';
// Fungsi helper untuk extract message dari response
function getMessageFromResponse(xhr) {
try {
const responseData = JSON.parse(xhr.responseText);
return responseData.message || responseData.error || responseData.msg || null;
} catch (e) {
return xhr.responseText || null;
}
}
// Parse error berdasarkan status code
switch (xhr.status) {
case 400:
errorTitle = 'Bad Request';
errorMessage = getMessageFromResponse(xhr) || 'Bad request. Please check your input.';
break;
case 401:
errorTitle = 'Unauthorized';
errorMessage = getMessageFromResponse(xhr) || 'You are not authorized to perform this action.';
break;
case 403:
errorTitle = 'Forbidden';
errorMessage = getMessageFromResponse(xhr) || 'Access denied. You do not have permission.';
break;
case 404:
errorTitle = 'Not Found';
errorMessage = getMessageFromResponse(xhr) || 'The requested resource was not found.';
break;
case 422:
errorTitle = 'Validation Error';
// Coba parse validation errors dari response
try {
const responseData = JSON.parse(xhr.responseText);
if (responseData.errors) {
const errors = Object.values(responseData.errors).flat();
errorMessage = errors.join('<br>');
} else if (responseData.message) {
errorMessage = responseData.message;
} else {
errorMessage = 'Validation failed. Please check your input.';
}
} catch (e) {
errorMessage = 'Validation failed. Please check your input.';
}
break;
case 500:
errorTitle = 'Server Error';
errorMessage = getMessageFromResponse(xhr) || 'Internal server error. Please try again later.';
break;
default:
// Coba parse pesan error dari response
try {
const responseData = JSON.parse(xhr.responseText);
if (responseData.message) {
errorMessage = responseData.message;
}
if (responseData.title) {
errorTitle = responseData.title;
}
} catch (e) {
errorMessage = getMessageFromResponse(xhr) || `Error ${xhr.status}: ${error}`;
}
}
showError(errorTitle, errorMessage);
}
// Fungsi untuk reset form error state
function resetFormErrors() {
$('.form-control').removeClass('input-error');
}
// Fungsi untuk highlight field error
function highlightFieldError(fieldName) {
$(`#${fieldName}`).addClass('input-error');
}
// Fungsi toggle password
function togglePassword() {
const passwordInput = document.getElementById('password');
const eyeIcon = document.getElementById('eyeIcon');
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
eyeIcon.classList.remove('fa-eye');
eyeIcon.classList.add('fa-eye-slash');
} else {
passwordInput.type = 'password';
eyeIcon.classList.remove('fa-eye-slash');
eyeIcon.classList.add('fa-eye');
}
}
// Setup CSRF token untuk Laravel
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
// Initialize Slider Captcha
let sliderCaptcha;
// Event handler untuk form login
$(document).ready(function() {
// Get container width for responsive captcha
const containerWidth = $('#loginForm').width();
// Initialize slider captcha
sliderCaptcha = new SliderCaptcha({
container: '#slider-captcha-container',
width: containerWidth || 400,
height: 150,
onSuccess: function(token) {
console.log('Captcha verified:', token);
// Enable login button
$('#loginButton').prop('disabled', false);
},
onFail: function() {
console.log('Captcha verification failed');
// Keep login button disabled
$('#loginButton').prop('disabled', true);
}
});
// Disable login button initially
$('#loginButton').prop('disabled', true);
$('#loginForm').on('submit', function(e) {
e.preventDefault();
// Reset error states
resetFormErrors();
// Ambil data form
const formData = new FormData(this);
const username = formData.get('username');
const password = formData.get('password');
// Validasi client-side
if (!username) {
showError('Validation Error', 'NIP tidak boleh kosong');
highlightFieldError('username');
return;
}
if (!password) {
showError('Validation Error', 'Password tidak boleh kosong');
highlightFieldError('password');
return;
}
// Check captcha verification
if (!sliderCaptcha.isVerified()) {
showError('Validation Error', 'Silakan selesaikan verifikasi captcha terlebih dahulu');
return;
}
// Add captcha token to form data
formData.append('captcha_token', sliderCaptcha.getToken());
// Ubah tombol menjadi loading
const loginBtn = $('.btn-login');
const originalBtnText = loginBtn.html();
loginBtn.html('<i class="fas fa-spinner fa-spin"></i> Memproses...');
loginBtn.prop('disabled', true);
// Kirim request AJAX
$.ajax({
url: "{{ route('authenticated') }}",
method: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(response, status, xhr) {
// Reset tombol
loginBtn.html(originalBtnText);
loginBtn.prop('disabled', false);
// Handle JSON response
if (response.success) {
showSuccess(
'Login Berhasil',
response.message ||
'Selamat datang! Anda akan diarahkan ke dashboard.'
);
// Redirect setelah 1.5 detik
setTimeout(function() {
window.location.href = response.redirect;
}, 2000);
} else {
showError(
'Login Gagal',
response.message || 'Terjadi Kesalahan Login.'
);
}
},
error: function(xhr, status, error) {
// Reset tombol
loginBtn.html(originalBtnText);
loginBtn.prop('disabled', false);
// Handle AJAX error
handleAjaxError(xhr, status, error);
// Highlight field yang error untuk 422 (validation)
if (xhr.status === 422) {
try {
const responseData = JSON.parse(xhr.responseText);
if (responseData.errors) {
Object.keys(responseData.errors).forEach(function(field) {
highlightFieldError(field);
});
}
} catch (e) {
// Ignore parsing error
}
}
}
});
});
// Remove error class when user types
$('.form-control').on('input', function() {
$(this).removeClass('input-error');
});
});
function loginWithGoogle() {
window.location.href = "{{ route('auth.google') }}";
}
// Animasi saat halaman dimuat
window.addEventListener('load', function() {
const container = document.querySelector('.login-wrapper');
container.style.opacity = '0';
container.style.transform = 'translateY(30px)';
setTimeout(() => {
container.style.transition = 'all 0.8s ease';
container.style.opacity = '1';
container.style.transform = 'translateY(0)';
}, 100);
});
// Flash Message Alert dari Session
@if (session('error'))
showError('Akses Ditolak', '{{ session('error') }}');
@endif
@if (session('success'))
showSuccess('Berhasil', '{{ session('success') }}');
@endif
@if (session('info'))
showInfo('Informasi', '{{ session('info') }}');
@endif
@if (session('warning'))
showWarning('Peringatan', '{{ session('warning') }}');
@endif
</script>
</body>
</html>