aboutsummaryrefslogtreecommitdiff
path: root/app/templates/signup.html
blob: a6d8fbfea941ba7ba00e8cb58cba146643f22402 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LinkLogger | Signup</title>
</head>
<body>
    <div>
        <p id="error"></p>
        <form action="/signup" method="POST">
            <input type="text" name="username" placeholder="Username" required>
            <input type="password" name="password" placeholder="Password" required>
            <button type="submit">Signup</button>
        </form>
        <hr>
        <p>Already have an account? <a href="/login">Log in now</a></p>
        <p>Passwords must be at least 8 characters long and contain a number, special character, and uppercase character.</p>
    </div>
</body>
</html>

<style>
    body {
        margin: 0;
        padding: 0;
        font-family: Arial, sans-serif;
        background-color: #2c3338;
    }

    div {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        text-align: center;
        max-width: 330px;
    }

    input {
        display: block;
        margin: 10px auto;
        width: 300px;
        border-radius: 5px;
        padding: 15px;
        color: #ccc;
        background-color: #3b4148;
        border: none;
        font-size: 17px;
    }

    button {
        display: block;
        margin: 10px auto;
        width: 100%;
        border-radius: 5px;
        padding: 15px;
        color: #ccc;
        background-color: #415eac;
        border: none;
        font-size: 17px;
        cursor: pointer;
    }

    hr {
        color: #606468;
    }

    p {
        color: #606468;
    }

    #error {
        font-size: 15px;
        color: #f55757;
        display: none;
    }

    a {
        color: #ccc;
        text-decoration: none;
    }

    a:hover {
        text-decoration: underline;
    }
</style>

<script>
    document.querySelector('form').addEventListener('submit', async function(event) {
        // Prevent default form submission
        event.preventDefault();

        // Get form data
        const formData = new FormData(this);

        console.log(formData)

        // Send POST request to /signup containing form data
        const response = await fetch('/signup', {
            method: 'POST',
            body: formData
        });

        data = await response.json()

        if (data.status != "success") {
            document.getElementById('error').style.display = 'block';
            document.getElementById('error').innerText = data.status;
        } else {
            window.location.href = '/dashboard';
        }
    });
</script>