Merge of dev-auth #1

Merged
AINDUSTRIES merged 28 commits from dev-auth into main 2024-10-05 13:58:45 +00:00
3 changed files with 141 additions and 0 deletions
Showing only changes of commit 19fe28be49 - Show all commits

86
static/css/login.css Normal file
View File

@@ -0,0 +1,86 @@
body {
background-color: #11111b;
padding:0;
margin:0;
}
.footer {
margin: 0;
position: fixed;
bottom: 0;
width: 100%;
max-height: 50px;
display: flex;
background-color: #b4befe;
justify-content: center;
}
.footer > a {
padding: 10px;
margin: 5px;
background-color: #94e2d5;
border-radius: 5px;
color: #1e1e2e;
font-family: "Segoe UI";
font-size: 14px;
}
.app {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, calc(-50% - 60px));
background-color: #181926;
border-radius: 12px;
width: 100%;
max-width: 500px;
height: fit-content;
padding: 10px;
}
.app > h1 {
margin-top: 5px;
color: yellow;
}
.app > h3 {
color: red;
}
.sub {
display: grid;
width: fit-content;
margin: auto;
}
.sub > input {
margin-bottom: 5px;
width: 300px;
color: black;
}
.sub > label {
color: white;
}
.sub > button {
justify-self: right;
font-size: 14px;
margin: 4px 0 0 0;
padding: 5px;
background-color: cornflowerblue;
color: white;
border: none;
border-radius: 5px;
}
.app > p {
text-align: center;
color: white;
}
.app > a {
display: flow;
text-align: center;
color: white;
}

37
static/html/login.html Normal file
View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<base href="/" target="_top">
<script src="static/js/login.js" defer="defer"></script>
<link rel="stylesheet" href="static/css/login.css">
<title>Login</title>
</head>
<body>
<div class="app">
<h1>Connection</h1>
<h3 id="message"></h3>
<div class="sub">
<label for="username">Nom d'utilisateur:</label>
<br>
<input id="username">
<br>
<label for="password">Mot de passe:</label>
<br>
<input id="password" type="password">
<br>
<button id="connect">Se connecter</button>
</div>
<p>Tu n'as pas de compte?</p>
<a href="/register">Créer un compte.</a>
</div>
<div id="footer" class="footer">
<a href="/">Voter</a>
<a href="/results">Résultats</a>
<a href="/archives">Archives</a>
</div>
</body>
</html>

18
static/js/login.js Normal file
View File

@@ -0,0 +1,18 @@
async function login() {
let username = document.getElementById("username").value;
let password = document.getElementById("password").value;
let code = await fetch("/login",
{method: "POST", body: JSON.stringify({"username": username, "password": password})})
.then(r => {
if (r.status === 400) {
let message = document.getElementById("message");
message.textContent = "Mauvais mot de passe/nom d'utilisateur!";
} else {
window.location.href = "/"}
});
}
let button = document.getElementById("connect");
button.addEventListener("click", () => {
let _ = login();
})