V1.0.0-beta.16 Update
All checks were successful
continuous-integration/drone/push Build is passing

Note: We appreciate your feedback and bug reports to continue improving our platform. Thank you for your continued support!
This commit is contained in:
2024-10-27 16:48:30 +01:00
parent f83358c67d
commit 9ff4642a10
33 changed files with 3550 additions and 2058 deletions

View File

@@ -1,287 +1,253 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<link rel="stylesheet" href="/public/css/login.css">
<title>Connexion</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--radius: 0.5rem;
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
}
body {
font-family: 'Inter', sans-serif;
background-color: hsl(var(--background));
color: hsl(var(--foreground));
transition: background-color 0.3s ease, color 0.3s ease;
}
.container {
max-width: 960px;
margin: 0 auto;
padding: 2rem;
}
.form-container {
background-color: hsl(var(--card));
border: 1px solid hsl(var(--border));
border-radius: var(--radius);
padding: 2rem;
}
.form-group {
margin-bottom: 1rem;
}
.form-control {
width: 100%;
padding: 0.5rem;
border: 1px solid hsl(var(--border));
border-radius: var(--radius);
background-color: hsl(var(--background));
color: hsl(var(--foreground));
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: var(--radius);
font-weight: 500;
transition: all 0.3s ease;
cursor: pointer;
}
.btn-primary {
background-color: hsl(var(--primary));
color: hsl(var(--primary-foreground));
}
.btn-primary:hover {
opacity: 0.9;
}
.btn-secondary {
background-color: hsl(var(--secondary));
color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover {
opacity: 0.9;
}
#themeSwitcher {
position: fixed;
top: 1rem;
right: 1rem;
}
.animate {
animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.icon-spacing {
margin-right: 8px;
}
</style>
</head>
<body class="animate">
<div id="app" class="min-h-screen flex items-center justify-center">
<div class="container mt-8">
<h1 class="text-3xl font-semibold mb-6 text-center animate">Connexion</h1>
<style>
.custom-btn {
display: inline-flex;
align-items: center;
justify-content: center;
font-family: inherit;
font-weight: 500;
font-size: 17px;
padding: 0.8em 1.5em;
color: white;
background: linear-gradient(0deg, rgba(77,54,208,1) 0%, rgba(132,116,254,1) 100%);
border: none;
box-shadow: 0 0.7em 1.5em -0.5em #4d36d0be;
letter-spacing: 0.05em;
border-radius: 20em;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
min-width: 150px;
min-height: 50px;
}
<div class="form-container">
<form id="loginForm" class="mb-4 animate">
<div class="form-group animate">
<label for="username" class="block mb-2">Nom d'utilisateur</label>
<input type="text" id="username" name="username" class="form-control" required>
</div>
.custom-btn:hover {
box-shadow: 0 0.5em 1.5em -0.5em #4d36d0be;
}
<div class="form-group animate">
<label for="password" class="block mb-2">Mot de passe</label>
<input type="password" id="password" name="password" class="form-control" required>
</div>
.custom-btn span {
position: relative;
z-index: 1;
transition: opacity 0.3s ease;
}
<button type="submit" id="loginButton" class="btn btn-primary w-full py-2 mt-4">
<i class="fa-solid fa-user icon-spacing"></i>
Se connecter
</button>
.custom-btn.processing {
cursor: wait;
}
.custom-btn.success {
background: linear-gradient(0deg, rgba(40,167,69,1) 0%, rgba(76,203,112,1) 100%);
box-shadow: 0 0.7em 1.5em -0.5em rgba(40,167,69,0.6);
}
.custom-btn.failure {
background: linear-gradient(0deg, rgba(220,53,69,1) 0%, rgba(255,107,114,1) 100%);
box-shadow: 0 0.7em 1.5em -0.5em rgba(220,53,69,0.6);
}
.custom-btn svg {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0);
width: 24px;
height: 24px;
transition: transform 0.3s ease;
}
.custom-btn.success svg, .custom-btn.failure svg {
transform: translate(-50%, -50%) scale(1);
}
.checkmark__circle, .crossmark__circle {
stroke-dasharray: 166;
stroke-dashoffset: 166;
stroke-width: 2;
stroke-miterlimit: 10;
stroke: #fff;
fill: none;
animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.checkmark__check, .crossmark__check {
transform-origin: 50% 50%;
stroke-dasharray: 48;
stroke-dashoffset: 48;
stroke: #fff;
stroke-width: 3;
fill: none;
animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
@keyframes stroke {
100% {
stroke-dashoffset: 0;
}
}
@keyframes fadeOutContent {
to {
opacity: 0;
}
}
@keyframes shakeButton {
0%, 100% {
transform: translateX(0);
}
10%, 30%, 50%, 70%, 90% {
transform: translateX(-5px);
}
20%, 40%, 60%, 80% {
transform: translateX(5px);
}
}
.custom-btn.processing span, .custom-btn.success span, .custom-btn.failure span {
animation: fadeOutContent 0.3s forwards;
}
.custom-btn.failure {
animation: shakeButton 0.5s cubic-bezier(.36,.07,.19,.97) both;
}
</style>
<body class="light-mode animate">
<div class="alert alert-primary text-center" role="alert">
Un nouveau look sera bientôt disponible pour la page de connexion. Myaxrin Labs va améliorer son application pour la rendre plus rapide et plus facile à utiliser.
</div>
<div class="container mt-4 animate">
<h1 class="title text-center animate">Connexion</h1>
<% if (currentUrl === '/auth/activedirectory' || (setupData[0] && setupData[0].hasOwnProperty('ldap'))) { %>
<h3 class="text-center animate">Connexion avec Active Directory</h3>
<form id="loginForm" class="mb-4 animate">
<% if (typeof errorMessage !== 'undefined' && errorMessage) { %>
<% } %>
<div class="form-group animate">
<label for="username" class="animate">Nom d'utilisateur :</label>
<input type="text" id="username" name="username" class="form-control animate" required>
<% if (typeof setupData !== 'undefined' && Array.isArray(setupData)) { %>
<% setupData.forEach(config => { %>
<% if (config.hasOwnProperty('discord') && config.discord.enabled === 'on' && config.discord.identifyURL) { %>
<button onclick="redirectToDiscord('<%= config.discord.identifyURL %>')" id="discordButton" class="btn btn-secondary w-full py-2 mt-4">
<i class="fab fa-discord mr-2"></i>
Se connecter avec Discord
</button>
<% } %>
<% }); %>
<% } %>
</form>
</div>
<div class="form-group animate">
<label for="password" class="animate">Mot de passe :</label>
<input type="password" id="password" name="password" class="form-control animate" required>
</div>
<button type="submit" id="loginButton" class="btn btn-primary d-flex align-items-center justify-content-center mx-auto d-block custom-btn">
<span class="ml-2 animate">Se connecter</span>
</button>
</form>
<% } %>
<% if (Array.isArray(setupData)) { %>
<% setupData.forEach(config => { %>
<% if (config.hasOwnProperty('discord') && config.discord.enabled === 'on') { %>
<% if (config.hasOwnProperty('ldap') && config.ldap.enabled === 'on') { %>
<h3 class="text-center animate">Ou</h3>
<% } %>
<button onclick="redirectToDiscord('<%= config.discord.identifyURL %>')" class="btn btn-primary d-flex align-items-center justify-content-center mx-auto d-block custom-btn" id="discordButton">
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="24" height="24">
<title>Discord</title>
<path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152..."></path>
</svg>&nbsp;Se connecter avec Discord
</button>
<% } %>
<% }); %>
<% } %>
<br>
<div class="d-flex justify-content-center animate">
<button id="themeSwitcher" class="btn btn-warning mt-3 animate">Changer de Thème</button>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<button id="themeSwitcher" class="btn btn-secondary p-2">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z" />
</svg>
</button>
<script>
const body = document.body;
const themeSwitcher = document.getElementById('themeSwitcher');
document.getElementById('themeSwitcher').addEventListener('click', function () {
body.classList.toggle('dark-mode');
function setTheme(theme) {
if (theme === 'dark') {
body.classList.add('dark');
} else {
body.classList.remove('dark');
}
localStorage.setItem('theme', theme);
}
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
setTheme(savedTheme);
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
setTheme('dark');
}
themeSwitcher.addEventListener('click', function() {
if (body.classList.contains('dark')) {
setTheme('light');
} else {
setTheme('dark');
}
});
document.addEventListener('DOMContentLoaded', function () {
const darkModeSwitch = document.getElementById('darkModeSwitch');
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(function (e) {
body.classList.toggle('dark-mode', e.matches);
});
});
document.addEventListener('DOMContentLoaded', function() {
const loginForm = document.getElementById('loginForm');
document.getElementById('loginForm').addEventListener('submit', function(e) {
e.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const loginButton = document.getElementById('loginButton');
loginForm.addEventListener('submit', function(e) {
e.preventDefault();
loginButton.disabled = true;
loginButton.innerHTML = 'Connexion en cours...';
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
loginButton.disabled = true;
loginButton.innerHTML = '<span>Connexion en cours...</span>';
loginButton.classList.add('processing');
fetch('/auth/activedirectory', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ username, password }),
redirect: 'follow',
})
.then(response => {
console.log('Statut de la réponse:', response.status);
console.log('URL finale:', response.url);
if (response.url.includes('/dpanel/dashboard')) {
handleAuthResult(loginButton, true);
} else {
return response.text().then(text => {
console.log('Texte reçu:', text);
handleAuthResult(loginButton, false);
});
}
})
.catch(error => {
console.error('Erreur:', error);
handleAuthResult(loginButton, false);
});
});
function handleAuthResult(loginButton, isSuccess) {
loginButton.classList.remove('processing');
loginButton.classList.add(isSuccess ? 'success' : 'failure');
const iconSVG = isSuccess ? `
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52" width="20" height="20">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
</svg>
` : `
<svg class="crossmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52" width="20" height="20">
<circle class="crossmark__circle" cx="26" cy="26" r="25" fill="none"/>
<path class="crossmark__check" fill="none" d="M16 16 36 36 M36 16 16 36"/>
</svg>
`;
loginButton.innerHTML = iconSVG;
if (isSuccess) {
setTimeout(() => {
console.log("Redirection vers /dpanel/dashboard");
window.location.replace('/dpanel/dashboard');
}, 1000);
fetch('/auth/activedirectory', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password }),
redirect: 'follow',
})
.then(response => {
if (response.url.includes('/dpanel/dashboard')) {
loginButton.innerHTML = 'Succès!';
setTimeout(() => window.location.replace('/dpanel/dashboard'), 1000);
} else {
setTimeout(() => {
loginButton.classList.remove('failure');
loginButton.innerHTML = '<span>Se connecter</span>';
loginButton.disabled = false;
}, 1500);
throw new Error('Échec de la connexion');
}
}
})
.catch(error => {
loginButton.innerHTML = 'Échec';
setTimeout(() => {
loginButton.disabled = false;
loginButton.innerHTML = 'Se connecter';
}, 1500);
});
});
function redirectToDiscord(url) {
const discordButton = document.getElementById('discordButton');
discordButton.classList.add('btn-fill');
discordButton.innerHTML = '<span>Redirection en cours...</span>';
discordButton.disabled = true;
setTimeout(() => {
window.location.href = url;
}, 1000);
if (discordButton) {
discordButton.innerHTML = 'Redirection en cours...';
discordButton.disabled = true;
setTimeout(() => window.location.href = url, 1000);
}
}
</script>
</body>
</html>
</html>