fix: BUG-012 remove email requirement from free signup + fix 429 handling

This commit is contained in:
OpenClaw 2026-02-14 17:24:03 +00:00
parent 73bb041513
commit 3c0bac889a
4 changed files with 35 additions and 37 deletions

View file

@ -2,9 +2,9 @@ function openSignup() {
document.getElementById('signupModal').classList.add('active');
document.getElementById('signupForm').style.display = 'block';
document.getElementById('keyResult').style.display = 'none';
document.getElementById('signupEmail').value = '';
document.getElementById('signupError').style.display = 'none';
setTimeout(function() { document.getElementById('signupEmail').focus(); }, 100);
document.getElementById('signupBtn').textContent = 'Get API Key';
document.getElementById('signupBtn').disabled = false;
}
function closeSignup() {
@ -16,35 +16,33 @@ document.getElementById('signupModal').addEventListener('click', function(e) {
if (e.target === this) closeSignup();
});
// Submit on Enter
document.getElementById('signupEmail').addEventListener('keydown', function(e) {
if (e.key === 'Enter') submitSignup();
});
async function submitSignup() {
var email = document.getElementById('signupEmail').value.trim();
var errEl = document.getElementById('signupError');
var btn = document.getElementById('signupBtn');
if (!email) {
errEl.textContent = 'Please enter your email.';
errEl.style.display = 'block';
return;
}
btn.textContent = 'Creating...';
btn.disabled = true;
errEl.style.display = 'none';
try {
var res = await fetch('/v1/signup/free', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: email })
body: JSON.stringify({})
});
if (res.status === 429) {
errEl.textContent = 'Too many requests. Please try again in a few minutes.';
errEl.style.display = 'block';
btn.textContent = 'Get API Key';
btn.disabled = false;
return;
}
var data = await res.json();
if (!res.ok) {
errEl.textContent = data.error || 'Something went wrong.';
errEl.textContent = data.error || 'Something went wrong. Please try again.';
errEl.style.display = 'block';
btn.textContent = 'Get API Key';
btn.disabled = false;
@ -72,7 +70,6 @@ function copyKey() {
}
try {
navigator.clipboard.writeText(key).then(showCopied).catch(function() {
// Fallback for older browsers / non-secure contexts
var ta = document.createElement('textarea');
ta.value = key; ta.style.position = 'fixed'; ta.style.opacity = '0';
document.body.appendChild(ta); ta.select();