This commit is contained in:
2025-09-06 16:26:26 +03:00
parent cd99fea483
commit 81e68770c6
22 changed files with 1777 additions and 23 deletions

View File

@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{% endblock %}</title>
<link href="css/global.css" rel="stylesheet">
<script src="/js/global.js"></script>
<script src="/js/global.js" defer></script>
{% block headers %}{% endblock %}
</head>
<body>
@@ -25,6 +25,9 @@
</button>
</div>
<div>
<button id="topnav_login" class="topnav_button" onclick="location.href='/login'">Login</button>
<div id="topnav_profile">
<span>MCorange</span>
<img src="/img/default_pfp.png" alt="Profile Picture" onclick="on_pfp_click()">

26
templates/login.html Normal file
View File

@@ -0,0 +1,26 @@
{% extends "base.html" %}
{% block title %}Login{% endblock %}
{% block headers %}
{% endblock %}
{% block content %}
<h1>Login</h1>
<form action="/api/user/login" method="POST">
<div>
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
</div>
<div>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit">Login</button>
</form>
<div>
No account yet?
<a href="/register">Register here!</a>
</div>
{% endblock %}

71
templates/register.html Normal file
View File

@@ -0,0 +1,71 @@
{% extends "base.html" %}
{% block title %}Register{% endblock %}
{% block headers %}
{% endblock %}
{% block content %}
<h1>Login</h1>
<form action="/api/user/register" method="POST">
<div>
<label for="email">Email:</label>
<input type="text" id="email" name="email">
<span id="email_error" style="color:red; margin-left:5px;"></span>
</div>
<div>
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<span id="username_error" style="color:red; margin-left:5px;"></span>
</div>
<div>
<label for="username">Password:</label>
<input type="password" id="password" name="password">
<span id="password_error" style="color:red; margin-left:5px;"></span>
</div>
<div>
<label for="password">Password:</label>
<input type="password" id="password2">
<span id="confirm_error" style="color:red; margin-left:5px;"></span>
</div>
<button type="submit" id="submit_btn">Register</button>
</form>
<script>
const password = document.getElementById('password');
const password2 = document.getElementById('password2');
const submit_btn = document.getElementById('submit_btn');
const username = document.getElementById('username');
const email = document.getElementById('email');
// const password_error = document.getElementById('password_error');
// const password2_error = document.getElementById('confirm_error');
function validate() {
submit_btn.disabled = false;
if (!(password.value && password2.value) || password.value !== password2.value) {
submit_btn.disabled = true;
} else {
}
if (password.length < 8) {
submit_btn.disabled = true;
}
if (username.length < 3) {
submit_btn.disabled = true;
}
if (email.length < 5) {
submit_btn.disabled = true;
}
}
// check on every key press
password.addEventListener('input', validate);
confirmPassword.addEventListener('input', validate);
username.addEventListener("input", validate);
email.addEventListener("input", validate);
</script>
{% endblock %}