aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/login.ts
blob: d8054c0d8e657999a933e33b88dfa79e84905dfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const loginForm = document.getElementById('login-form') as HTMLFormElement;
const handleInput = document.getElementById('handle-input') as HTMLInputElement;
const loginError = document.getElementById('login-error') as HTMLDivElement;

loginForm.addEventListener('submit', async (e) => {
  e.preventDefault();
  const handle = handleInput.value.trim();

  if (!handle) {
    loginError.textContent = 'please enter a handle';
    return;
  }

  loginError.textContent = '';
  window.location.href = `/api/login?handle=${encodeURIComponent(handle)}`;
});