mirror of
https://github.com/Damillora/Shioriko.git
synced 2024-11-22 12:27: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 username = "";
|
||||||
let password = "";
|
let password = "";
|
||||||
|
let error = "";
|
||||||
|
|
||||||
const doLogin = async () => {
|
const doLogin = async () => {
|
||||||
|
error = "";
|
||||||
|
try {
|
||||||
const tokenData = await login({ username, password });
|
const tokenData = await login({ username, password });
|
||||||
navigate("/");
|
navigate("/");
|
||||||
|
} catch (e) {
|
||||||
|
error = "We had trouble logging you in";
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -45,6 +52,11 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{#if error}
|
||||||
|
<div class="field">
|
||||||
|
<p class="has-text-danger">{error}</p>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button class="button is-link">Login</button>
|
<button class="button is-link">Login</button>
|
||||||
|
@ -5,10 +5,15 @@
|
|||||||
let username = "";
|
let username = "";
|
||||||
let password = "";
|
let password = "";
|
||||||
let email = "";
|
let email = "";
|
||||||
|
let error = "";
|
||||||
|
|
||||||
const doRegister = async () => {
|
const doRegister = async () => {
|
||||||
|
try {
|
||||||
const tokenData = await register({ email, username, password });
|
const tokenData = await register({ email, username, password });
|
||||||
navigate("/");
|
navigate("/");
|
||||||
|
} catch (error) {
|
||||||
|
error = "We had trouble registering you";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user