-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinscription.html
executable file
·69 lines (69 loc) · 3.24 KB
/
inscription.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Signup</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body id="inscription" class="h-screen w-screen flex justify-center items-center">
<div id="pgconnexion" class=" rounded-lg shadow-md">
<H1 class="text-center text-black font-bold w-full m-2">Inscription</H1>
<form name="form_signup" class="flex flex-col">
<div class="m-2">
<input type="email" name="mail" id="mail" placeholder="Email" class="border border-gray-800 rounded-md pl-2 w-full">
</div>
<div class="m-2">
<input type="password" name="pass" id="pass" placeholder="Mot de passe" class="border border-gray-800 rounded-md pl-2 w-full">
</div>
<div class="m-2">
<input type="text" name="name" id="pseudo" placeholder="Pseudo" class="border border-gray-800 rounded-md pl-2 w-full">
</div>
<p class="text-black hover:text-blue-400 ml-2"><a href="/login">I have alredy a account</a></p>
<input type="button" onclick="signup()" class=" text-white font-bold m-1 rounded-sm p-2 bg-blue-500 hover:bg-blue-400" value="S'inscrire" name="connexion" id="connexion" >
</form>
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
var token = function() {
return Math.random().toString(36).substr(2) + Math.random().toString(36).substr(2); // remove `0.`
};
var token = token();
var signup = function() {
var email = document.getElementById('mail').value;
var password = document.getElementById('pass').value;
var pseudo = document.getElementById('pseudo').value;
if (email != "" && password != "" && pseudo != "") {
socket.emit("create_user", {token : token, email : email, password : password, pseudo : pseudo, server : window.location.hostname});
} else {
document.getElementById('error').innerHTML = "Fill all inputs";
}
}
window.onload = function () {
socket.on("anwser_bdd_account :"+token, (data) => {
if (data.status == "success") {
sessionStorage.setItem('Token', data.token);
console.log('e');
window.location.href = "/";
} else {
document.getElementsByName('form_signup').innerHTML += `<p id="error" class="text-red-500 text-center p-2 text-md font-bold">${data.message}</p>`;
}
});
}
</script>
</div>
</body>
<style>
#inscription{
background-image: url("build/img/inscription.jpg");
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
#pgconnexion{
background-color: rgba(255,255,255,0.95);
}
</style>
</html>