feat: validation for login and register

This commit is contained in:
Damillora 2021-05-21 18:51:44 +07:00
parent 4cac39e83f
commit e79b033c59
2 changed files with 22 additions and 5 deletions

View File

@ -4,10 +4,17 @@
let username = "";
let password = "";
let error = "";
const doLogin = async () => {
error = "";
try {
const tokenData = await login({ username, password });
navigate("/");
} catch (e) {
error = "We had trouble logging you in";
return;
}
};
</script>
@ -45,6 +52,11 @@
/>
</div>
</div>
{#if error}
<div class="field">
<p class="has-text-danger">{error}</p>
</div>
{/if}
<div class="field">
<div class="control">
<button class="button is-link">Login</button>

View File

@ -5,10 +5,15 @@
let username = "";
let password = "";
let email = "";
let error = "";
const doRegister = async () => {
try {
const tokenData = await register({ email, username, password });
navigate("/");
} catch (error) {
error = "We had trouble registering you";
}
};
</script>