feat: username field in market registration
This commit is contained in:
@@ -533,6 +533,7 @@ async def api_market_register(data: dict):
|
||||
"email": data.get("email"),
|
||||
"password": data.get("password"),
|
||||
"passwordConfirm": data.get("passwordConfirm"),
|
||||
"name": data.get("name", ""),
|
||||
}
|
||||
)
|
||||
return resp.json()
|
||||
|
||||
@@ -97,6 +97,7 @@ const PageMarket = {
|
||||
overlay.innerHTML = `<div class="modal" style="min-width:360px;max-width:400px">
|
||||
<h3>市场账户</h3>
|
||||
<div class="form-group"><label>邮箱</label><input id="ml-email" type="email" placeholder="your@email.com"></div>
|
||||
<div class="form-group"><label>用户名</label><input id="ml-name" type="text" placeholder="可选"></div>
|
||||
<div class="form-group"><label>密码</label><input id="ml-pass" type="password"></div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-secondary btn-sm" id="ml-logout" style="display:none;margin-right:auto">退出</button>
|
||||
@@ -136,8 +137,9 @@ const PageMarket = {
|
||||
overlay.querySelector('#ml-register')?.addEventListener('click', async () => {
|
||||
const email = document.getElementById('ml-email').value;
|
||||
const pass = document.getElementById('ml-pass').value;
|
||||
const name = document.getElementById('ml-name')?.value || '';
|
||||
if (!email || !pass) { Toast.show('请输入邮箱和密码', 'error'); return; }
|
||||
const res = await fetch('/api/market/register', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify({email, password: pass, passwordConfirm: pass}) });
|
||||
const res = await fetch('/api/market/register', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify({email, password: pass, passwordConfirm: pass, name}) });
|
||||
const data = await res.json();
|
||||
Toast.show(data.error ? '注册失败' : '注册成功,请查收验证邮件', data.error ? 'error' : 'success');
|
||||
if (!data.error) overlay.remove();
|
||||
|
||||
Reference in New Issue
Block a user