Files / templates /login.html
lea97338's picture
Upload 2 files
b266b9e verified
Raw
History Blame Contribute Delete
11.5 kB
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>Connexion - Gestionnaire de Fichiers Pro</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet"/>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-container {
background: white;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0,0,0,0.2);
padding: 40px;
width: 400px;
max-width: 90vw;
text-align: center;
}
.login-header {
margin-bottom: 30px;
}
.login-icon {
width: 80px;
height: 80px;
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 20px;
color: white;
font-size: 32px;
}
.login-title {
font-size: 24px;
color: #333;
margin-bottom: 8px;
font-weight: 700;
}
.login-subtitle {
color: #666;
font-size: 14px;
}
.login-form {
margin-bottom: 20px;
}
.form-group {
margin-bottom: 20px;
text-align: left;
}
.form-label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 500;
font-size: 14px;
}
.form-input {
width: 100%;
padding: 12px 16px;
border: 2px solid #e1e5e9;
border-radius: 8px;
font-size: 16px;
transition: border-color 0.3s ease;
outline: none;
}
.form-input:focus {
border-color: #4facfe;
box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}
.login-btn {
width: 100%;
padding: 12px;
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.login-btn:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(79, 172, 254, 0.3);
}
.login-btn:active {
transform: translateY(0);
}
.login-btn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.error-message {
background: #fee;
color: #c33;
padding: 12px;
border-radius: 8px;
margin-bottom: 20px;
border: 1px solid #fcc;
display: none;
}
.success-message {
background: #efe;
color: #3c3;
padding: 12px;
border-radius: 8px;
margin-bottom: 20px;
border: 1px solid #cfc;
display: none;
}
.loading {
display: none;
margin-left: 8px;
}
.loading i {
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.login-footer {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid #e1e5e9;
color: #666;
font-size: 12px;
}
.demo-accounts {
background: #f8f9fa;
border-radius: 8px;
padding: 15px;
margin-top: 20px;
text-align: left;
}
.demo-title {
font-weight: 600;
color: #333;
margin-bottom: 10px;
text-align: center;
}
.demo-account {
display: flex;
justify-content: space-between;
padding: 5px 0;
font-size: 13px;
color: #555;
}
.demo-account:hover {
background: #e9ecef;
border-radius: 4px;
padding: 5px 8px;
cursor: pointer;
}
.admin-badge {
background: #dc3545;
color: white;
font-size: 10px;
padding: 2px 6px;
border-radius: 10px;
margin-left: 5px;
}
/* Responsive */
@media (max-width: 480px) {
.login-container {
padding: 30px 20px;
}
.login-icon {
width: 60px;
height: 60px;
font-size: 24px;
}
.login-title {
font-size: 20px;
}
}
/* Animation d'entrée */
.login-container {
animation: slideIn 0.5s ease-out;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-header">
<div class="login-icon">
<i class="fas fa-folder-open"></i>
</div>
<h1 class="login-title">Gestionnaire de Fichiers Pro</h1>
<p class="login-subtitle">Connectez-vous pour accéder à vos fichiers</p>
</div>
<div class="error-message" id="error-message">
Identifiants incorrects. Veuillez réessayer.
</div>
<div class="success-message" id="success-message">
Connexion réussie ! Redirection en cours...
</div>
<form class="login-form" id="login-form">
<div class="form-group">
<label class="form-label" for="username">
<i class="fas fa-user"></i> Identifiant
</label>
<input autocomplete="username" class="form-input" id="username" placeholder="Entrez votre identifiant" required="" type="text"/>
</div>
<div class="form-group">
<label class="form-label" for="password">
<i class="fas fa-lock"></i> Mot de passe
</label>
<input autocomplete="current-password" class="form-input" id="password" placeholder="Entrez votre mot de passe" required="" type="password"/>
</div>
<button class="login-btn" id="login-btn" type="submit">
<span><i class="fas fa-sign-in-alt"></i> Se connecter</span>
<span class="loading" id="loading">
<i class="fas fa-spinner"></i>
</span>
</button>
</form>
<div class="demo-accounts">
<div class="demo-title">👥 Comptes de démonstration</div>
<div class="demo-account" onclick="fillCredentials('admin', 'admin123')">
<span><strong>admin</strong><span class="admin-badge">ADMIN</span></span>
<span>admin123</span>
</div>
<div class="demo-account" onclick="fillCredentials('user1', 'password1')">
<span><strong>user1</strong></span>
<span>password1</span>
</div>
<div class="demo-account" onclick="fillCredentials('user2', 'password2')">
<span><strong>user2</strong></span>
<span>password2</span>
</div>
<div class="demo-account" onclick="fillCredentials('demo', 'demo')">
<span><strong>demo</strong></span>
<span>demo</span>
</div>
</div>
<div class="login-footer">
<p><i class="fas fa-folder-open" style="color: #4facfe; margin-right: 5px;"></i>Gestionnaire de fichiers sécurisé</p>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('login-form');
const usernameInput = document.getElementById('username');
const passwordInput = document.getElementById('password');
const loginBtn = document.getElementById('login-btn');
const loading = document.getElementById('loading');
const errorMessage = document.getElementById('error-message');
const successMessage = document.getElementById('success-message');
usernameInput.focus();
form.addEventListener('submit', function(e) {
e.preventDefault();
const username = usernameInput.value.trim();
const password = passwordInput.value.trim();
if (!username || !password) {
showError('Veuillez remplir tous les champs');
return;
}
loginBtn.disabled = true;
loading.style.display = 'inline';
hideMessages();
fetch('/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: username,
password: password
})
})
.then(response => response.json())
.then(data => {
loginBtn.disabled = false;
loading.style.display = 'none';
if (data.success) {
showSuccess('Connexion réussie ! Redirection...');
setTimeout(() => {
window.location.href = data.redirect;
}, 1500);
} else {
showError(data.error || 'Identifiants incorrects');
passwordInput.value = '';
usernameInput.focus();
}
})
.catch(error => {
loginBtn.disabled = false;
loading.style.display = 'none';
showError('Erreur de connexion. Veuillez réessayer.');
console.error('Erreur:', error);
});
});
[usernameInput, passwordInput].forEach(input => {
input.addEventListener('input', hideMessages);
});
function showError(message) {
errorMessage.textContent = message;
errorMessage.style.display = 'block';
successMessage.style.display = 'none';
}
function showSuccess(message) {
successMessage.textContent = message;
successMessage.style.display = 'block';
errorMessage.style.display = 'none';
}
function hideMessages() {
errorMessage.style.display = 'none';
successMessage.style.display = 'none';
}
});
function fillCredentials(username, password) {
document.getElementById('username').value = username;
document.getElementById('password').value = password;
document.getElementById('username').focus();
}
</script>
</body>
</html>