Plan stuff. Log stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

4 years ago
  1. <script>
  2. import ModalFrame from "../components/ModalFrame";
  3. import auth from "../stores/auth";
  4. import modal from "../stores/modal";
  5. function login(username, password) {
  6. auth.login(username, password).then(() => {
  7. modal.close();
  8. }).catch(err => {
  9. error = "Incorrect username or password."
  10. });
  11. }
  12. function register(username, password) {
  13. auth.register(username, password).then(() => {
  14. modal.close();
  15. }).catch(err => {
  16. error = "Incorrect username or password."
  17. });
  18. }
  19. let username = "";
  20. let password = "";
  21. let error = null;
  22. </script>
  23. <ModalFrame title="Login" error={error}>
  24. <form on:submit|preventDefault={() => {}}>
  25. <label>Username</label>
  26. <input type="text" bind:value={username} />
  27. <label>Password</label>
  28. <input type="password" bind:value={password} />
  29. <hr />
  30. <button type="submit" on:click={() => login(username, password)}>Login</button>
  31. <button type="submit" on:click={() => register(username, password)}>Register</button>
  32. </form>
  33. </ModalFrame>