Email validation: - Replace @/. check with net/mail.ParseAddress on register - Add size limit check (max 254 chars, RFC 5321) CI/CD Pipeline: - Add .gitea/workflows/ci.yml (lint → test → build → docker push) - Registry: gitea.mrixs.me/Mrixs/MrixsCraft-server - Push only on main branch Database: - Add migrations/002_migration_history.sql (tracking applied migrations) - Add migrations/README.md (manual apply instructions) Web Templates: - Add base.html with Minecraft-themed layout (dark + green accent) - Add index.html, login.html, register.html with POST forms - Rewrite templates.go for data-driven rendering with pageData struct - Fallback placeholder preserved when templates dir missing
44 lines
1.6 KiB
HTML
44 lines
1.6 KiB
HTML
{{define "content"}}
|
|
<div class="card">
|
|
<h1>Регистрация</h1>
|
|
<form id="regForm">
|
|
<label for="username">Никнейм</label>
|
|
<input type="text" id="username" name="username" required minlength="3" maxlength="20" autocomplete="username">
|
|
|
|
<label for="email">Email</label>
|
|
<input type="email" id="email" name="email" required autocomplete="email">
|
|
|
|
<label for="password">Пароль</label>
|
|
<input type="password" id="password" name="password" required minlength="6" autocomplete="new-password">
|
|
|
|
<button type="submit" class="btn">Создать аккаунт</button>
|
|
</form>
|
|
<p id="error" style="color: var(--error); margin-top: 0.75rem; display: none;"></p>
|
|
<p style="margin-top: 1rem;">Уже есть аккаунт? <a href="/login">Войти</a></p>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('regForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const form = new FormData(e.target);
|
|
const res = await fetch('/api/web/register', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
username: form.get('username'),
|
|
email: form.get('email'),
|
|
password: form.get('password')
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
if (!res.ok) {
|
|
document.getElementById('error').textContent = data.error || 'Ошибка регистрации';
|
|
document.getElementById('error').style.display = 'block';
|
|
return;
|
|
}
|
|
// Registration successful — go to login.
|
|
window.location.href = '/login';
|
|
});
|
|
</script>
|
|
{{end}}
|