Files
CDN-APP-INSIDER/views/AuthLogin.ejs
Dinawo 4e2e085a63
All checks were successful
continuous-integration/drone/push Build is passing
Update routes and file paths, fix authentication and security issues
2024-04-13 22:17:54 +02:00

149 lines
6.8 KiB
Plaintext

<!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" />
</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="light-mode animate">
<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 action="/auth/activedirectory" method="post" 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>
</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" 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 (typeof setupData.discord !== 'undefined') { %>
<% if (typeof setupData.ldap !== 'undefined') { %>
<h3 class="text-center animate">Ou</h3>
<% } %>
<button onclick="location.href='/auth/discord'" class="btn btn-primary d-flex align-items-center justify-content-center mx-auto d-block custom-btn">
<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.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"/>
</svg>
<span class="ml-2 animate">Se connecter avec Discord</span>
</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>
<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>
<script>
const body = document.body;
document.getElementById('themeSwitcher').addEventListener('click', function () {
body.classList.toggle('dark-mode');
});
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);
});
});
var isAuthenticated = "<%= isAuthenticated %>" === "true";
var errorMessage = '<%= errorMessage %>';
if (isAuthenticated) {
Swal.fire({
position: 'top',
icon: 'success',
title: 'Authentification réussie!',
text: 'Vous allez être redirigé vers le tableau de bord.',
showConfirmButton: false,
timer: 1800,
timerProgressBar: true,
toast: true,
willClose: () => {
window.location.replace('/dpanel/dashboard');
}
});
} else if (errorMessage) {
Swal.fire({
position: 'top',
icon: 'error',
title: 'Erreur lors de l\'authentification!',
text: 'Merci de reessayer.',
showConfirmButton: false,
timer: 2200,
timerProgressBar: true,
toast: true,
});
}
</script>
</body>
</html>