mirror of
https://github.com/Damillora/Shioriko.git
synced 2024-11-22 04:17:33 +00:00
feat: validation for login and register
This commit is contained in:
parent
4cac39e83f
commit
e79b033c59
@ -4,10 +4,17 @@
|
||||
|
||||
let username = "";
|
||||
let password = "";
|
||||
|
||||
let error = "";
|
||||
|
||||
const doLogin = async () => {
|
||||
const tokenData = await login({ username, password });
|
||||
navigate("/");
|
||||
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>
|
||||
|
@ -5,10 +5,15 @@
|
||||
let username = "";
|
||||
let password = "";
|
||||
let email = "";
|
||||
let error = "";
|
||||
|
||||
const doRegister = async () => {
|
||||
const tokenData = await register({ email, username, password });
|
||||
navigate("/");
|
||||
try {
|
||||
const tokenData = await register({ email, username, password });
|
||||
navigate("/");
|
||||
} catch (error) {
|
||||
error = "We had trouble registering you";
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user