123 lines
4.7 KiB
Plaintext
123 lines
4.7 KiB
Plaintext
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Fichier sécurisé</title>
|
|
<link rel="icon" href="/public/assets/homelab_logo.png" />
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
|
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
|
</head>
|
|
|
|
<style>
|
|
.custom-btn {
|
|
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
|
|
color: #007BFF;
|
|
background-color: transparent;
|
|
padding: 10px 20px;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
font-size: 16px;
|
|
margin: 4px 2px;
|
|
border-radius: 50px;
|
|
cursor: pointer;
|
|
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
|
|
border: 2px solid #007BFF;
|
|
}
|
|
|
|
.custom-btn:hover {
|
|
transform: scale(1.15);
|
|
background-color: #007BFF;
|
|
color: #fff;
|
|
}
|
|
|
|
.animate {
|
|
opacity: 0;
|
|
transform: translateY(-20px);
|
|
animation: slideIn 0.4s forwards;
|
|
animation-delay: 0.2s;
|
|
}
|
|
|
|
@keyframes slideIn {
|
|
100% {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<body class="bg-gray-900 text-white">
|
|
<div class="flex justify-center items-center h-screen animate">
|
|
<div class="max-w-md mx-auto bg-gray-800 p-8 rounded shadow-md">
|
|
<h1 class="text-3xl font-bold text-center mb-8">Entrer le mot de passe pour <%= filename %></h1>
|
|
<p class="text-center text-red-500 mb-4">Le fichier <span class="text-blue-500"><%= filename %></span> est protégé. Veuillez entrer le mot de passe pour y accéder.</p>
|
|
<form id="password-form" action="/attachments/<%= userId %>/<%= filename %>" method="post">
|
|
<div class="mb-4">
|
|
<label for="password" class="block text-gray-200 font-bold mb-2">Mot de passe :</label>
|
|
<input type="password" id="password" name="password" required class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-200 bg-gray-700 leading-tight focus:outline-none focus:shadow-outline">
|
|
</div>
|
|
<div class="flex justify-center">
|
|
<input type="submit" value="Soumettre" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline custom-btn">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
$('#password-form').on('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
const userId = '<%= userId %>';
|
|
const filename = '<%= filename %>';
|
|
const enteredPassword = $('#password').val();
|
|
|
|
if (!enteredPassword) {
|
|
Swal.fire({
|
|
position: 'top',
|
|
icon: 'error',
|
|
title: 'Password is required',
|
|
showConfirmButton: false,
|
|
timer: 1800,
|
|
toast: true
|
|
});
|
|
return;
|
|
}
|
|
|
|
$.post('/attachments/' + userId + '/' + filename, { password: enteredPassword })
|
|
.done(function(data) {
|
|
if (data.success) {
|
|
Swal.fire({
|
|
position: 'top',
|
|
icon: 'success',
|
|
title: 'Mot de passe correct',
|
|
text: 'Vous allez être redirigé vers le fichier !',
|
|
showConfirmButton: false,
|
|
timer: 1800,
|
|
toast: true
|
|
}).then(() => {
|
|
window.location.href = '/attachments/' + userId + '/' + filename;
|
|
});
|
|
} else {
|
|
Swal.fire({
|
|
position: 'top',
|
|
icon: 'error',
|
|
title: 'Mot de passe incorrect',
|
|
showConfirmButton: false,
|
|
timer: 1800,
|
|
toast: true
|
|
});
|
|
}
|
|
})
|
|
.fail(function() {
|
|
Swal.fire({
|
|
position: 'top',
|
|
icon: 'error',
|
|
title: 'Erreur lors de la vérification du mot de passe',
|
|
showConfirmButton: false,
|
|
timer: 1800,
|
|
toast: true
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |