-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogipaq.html
216 lines (202 loc) · 8.73 KB
/
logipaq.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login</title>
<!-- Bootstrap 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=Press+Start+2P&family=Signika:wght@300..700&family=Titan+One&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<link rel="shortcut icon" href="./Img/caja.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(183deg, rgba(255,102,102,1) 0%, rgba(139,0,0,1) 100%);
}
.login-container {
background-color: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
width: 100%;
max-width: 400px;
}
.custom-spinner {
width: 1.5rem;
height: 1.5rem;
margin-right: 8px;
}
.btn {
display: flex;
align-items: center;
justify-content: center;
}
.spinner-container2 {
display: flex;
align-items: center;
}
.input-group {
border: none;
position: relative;
height: 46px;
border-radius: 5px;
}
.eye-toggle {
border: 1px cornflowerblue solid;
height: 46px;
background-color: #ffffff;
border-radius: 5px;
padding: 6px;
display: flex;
align-items: center;
justify-content: center;
transition: background-color 0.3s, transform 0.2s;
}
.eye-toggle:hover {
background-color: cornflowerblue;
cursor: pointer;
}
.eye-toggle i {
color: #007bff;
font-size: 1.2rem;
cursor: pointer;
}
.eye-toggle i:hover {
color: white;
}
.form-control {
padding-right: 40px;
}
</style>
</head>
<body>
<div class="login-container text-center">
<h2 class="navbar-brand-text">Logi<span class="navbar-brand-text3">Paq</span></h2>
<form id="loginForm">
<div class="mb-3">
<input type="text" id="username" class="form-control" placeholder="Usuario" required>
</div>
<div class="mb-3">
<div class="input-group">
<input type="password" id="password" class="form-control" placeholder="Contraseña" required autocomplete="current-password">
<span class="eye-toggle" id="togglePassword">
<i class="fas fa-eye" id="eyeIcon"></i>
</span>
</div>
</div>
<button type="submit" id="loginButton" class="btn btn-primary w-100">
<div class="spinner-container2">
<span id="customSpinner" class="spinner-border custom-spinner d-none" role="status"></span>
<span id="buttonText">Ingresar</span>
</div>
</button>
</form>
<p id="errorMsg" class="text-danger mt-2 d-none"></p>
</div>
<!-- Firebase Scripts -->
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.0/firebase-database.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Configuración de Firebase
const firebaseConfig = {
apiKey: "AIzaSyBPw7ElqCPC92nag2oFW57aLD9t018FvC4",
authDomain: "emails-novogar.firebaseapp.com",
databaseURL: "https://emails-novogar-default-rtdb.firebaseio.com",
projectId: "emails-novogar",
storageBucket: "emails-novogar.appspot.com",
messagingSenderId: "1085815449583",
appId: "1:1085815449583:web:72f836c378bd971fb8b81a",
measurementId: "G-BW9ML8LVV6"
};
firebase.initializeApp(firebaseConfig);
const dbRef = firebase.database().ref('LogiPaq');
const loginForm = document.getElementById('loginForm');
const loginButton = document.getElementById('loginButton');
const customSpinner = document.getElementById('customSpinner');
const buttonText = document.getElementById('buttonText');
const errorMsg = document.getElementById('errorMsg');
function saveLoginTimestamp() {
localStorage.setItem('loginTimestamp', Date.now());
}
function isLoginExpired() {
const savedTimestamp = localStorage.getItem('loginTimestamp');
return !savedTimestamp || (Date.now() - savedTimestamp) > 10800000; // 3 horas
}
// Verificar si ya está logueado
if (!isLoginExpired()) {
window.location.href = 'index.html';
}
loginForm.addEventListener('submit', (e) => {
e.preventDefault();
const username = document.getElementById('username').value.trim();
const password = document.getElementById('password').value.trim();
loginButton.disabled = true;
customSpinner.classList.remove('d-none');
buttonText.textContent = 'Verificando datos...';
setTimeout(() => {
dbRef.once('value').then(snapshot => {
const data = snapshot.val();
if (data[1] === username && data[2] === password) {
buttonText.textContent = 'Ingresando';
loginButton.classList.replace('btn-primary', 'btn-success');
let countdown = 3;
const interval = setInterval(() => {
buttonText.textContent = `Ingresando (${countdown})`;
countdown--;
if (countdown < 0) {
clearInterval(interval);
saveLoginTimestamp();
window.location.href = 'index.html';
}
}, 1000);
} else {
loginButton.disabled = false;
customSpinner.classList.add('d-none');
loginButton.classList.replace('btn-primary', 'btn-danger');
buttonText.textContent = 'Contraseña incorrecta';
let countdown = 5;
errorMsg.textContent = `Reintento en ${countdown}...`;
errorMsg.classList.remove('d-none');
const interval = setInterval(() => {
countdown--;
errorMsg.textContent = `Reintento en ${countdown}...`;
if (countdown === 0) {
clearInterval(interval);
loginButton.classList.replace('btn-danger', 'btn-primary');
buttonText.textContent = 'Ingresar';
errorMsg.classList.add('d-none');
}
}, 1000);
}
}).catch(error => {
console.error('Error al conectar con Firebase:', error);
customSpinner.classList.add('d-none');
loginButton.disabled = false;
buttonText.textContent = 'Error de conexión';
});
}, 3000);
});
// Mostrar/Ocultar la contraseña
const togglePassword = document.getElementById('togglePassword');
const passwordInput = document.getElementById('password');
const eyeIcon = document.getElementById('eyeIcon');
togglePassword.addEventListener('click', () => {
// Alternar el tipo de input
const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
passwordInput.setAttribute('type', type);
// Alternar el ícono del ojo
eyeIcon.classList.toggle('fa-eye');
eyeIcon.classList.toggle('fa-eye-slash');
});
</script>
</body>
</html>