Merge pull request #16 from ANONYMOUSZED-beep/fix/database-concurrency-invariants

Enforce database concurrency invariants
This commit is contained in:
lezi authored and GitHub committed 2026-08-14 09:43:07 +08:00
commit bce8d1fdc7
6 files changed
+114 -31

No files matched your search

+2 -2
View File
@@ -35,10 +35,10 @@ const API = {
return data;
},
async register(email, password, username) {
async register(email, password, username, bootstrapToken = '') {
const data = await apiFetch('/auth/register', {
method: 'POST',
body: JSON.stringify({ email, password, username })
body: JSON.stringify({ email, password, username, bootstrap_token: bootstrapToken || undefined })
});
if (data.error) throw new Error(data.error);
return data;
+3 -1
View File
@@ -41,13 +41,14 @@ document.getElementById('registerSubmit').addEventListener('click', async () =>
const username = document.getElementById('regUsername').value.trim();
const email = document.getElementById('regEmail').value.trim();
const password = document.getElementById('regPassword').value;
const bootstrapToken = document.getElementById('regBootstrapToken').value.trim();
const captchaInput = document.getElementById('regCaptchaInput').value.trim();
const captchaAnswer = parseInt(document.getElementById('regCaptchaInput').dataset.answer);
if (!username || !email || !password) { alert('请填写完整信息'); return; }
if (password.length < 6) { alert('密码至少6位'); return; }
if (parseInt(captchaInput) !== captchaAnswer) { alert('验证码错误,请重新计算'); refreshCaptcha('reg'); return; }
try {
await API.register(email, password, username);
await API.register(email, password, username, bootstrapToken);
} catch (err) {
alert('注册失败:' + err.message);
return;
@@ -57,6 +58,7 @@ document.getElementById('registerSubmit').addEventListener('click', async () =>
document.getElementById('regUsername').value = '';
document.getElementById('regEmail').value = '';
document.getElementById('regPassword').value = '';
document.getElementById('regBootstrapToken').value = '';
document.getElementById('regCaptchaInput').value = '';
try {