mirror of
https://github.com/Damillora/Shioriko.git
synced 2024-11-25 05:27:32 +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 () => {
|
||||||
const tokenData = await login({ username, password });
|
error = "";
|
||||||
navigate("/");
|
try {
|
||||||
|
const tokenData = await login({ username, password });
|
||||||
|
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 () => {
|
||||||
const tokenData = await register({ email, username, password });
|
try {
|
||||||
navigate("/");
|
const tokenData = await register({ email, username, password });
|
||||||
|
navigate("/");
|
||||||
|
} catch (error) {
|
||||||
|
error = "We had trouble registering you";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user