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.
 
 
 
 
 

40 lines
1.0 KiB

<script>
import ModalFrame from "../components/ModalFrame";
import auth from "../stores/auth";
import modal from "../stores/modal";
function login(username, password) {
auth.login(username, password).then(() => {
modal.close();
}).catch(err => {
error = "Incorrect username or password."
});
}
function register(username, password) {
auth.register(username, password).then(() => {
modal.close();
}).catch(err => {
error = "Incorrect username or password."
});
}
let username = "";
let password = "";
let error = null;
</script>
<ModalFrame title="Login" error={error}>
<form on:submit|preventDefault={() => {}}>
<label>Username</label>
<input type="text" bind:value={username} />
<label>Password</label>
<input type="password" bind:value={password} />
<hr />
<button type="submit" on:click={() => login(username, password)}>Login</button>
<button type="submit" on:click={() => register(username, password)}>Register</button>
</form>
</ModalFrame>