Implement authentication in frontend
This commit is contained in:
@@ -23,20 +23,19 @@
|
||||
return extractFromErrorFromField("Password", errors.value);
|
||||
})
|
||||
|
||||
function onSubmit(e) {
|
||||
postLogin(user)
|
||||
.then((res) => {
|
||||
if (res.ok) {
|
||||
res.json().then((json) => login(user.value.username, json));
|
||||
router.push('/');
|
||||
return;
|
||||
} else {
|
||||
res.json().then((json) => (errors.value = json));
|
||||
}
|
||||
})
|
||||
async function onSubmit(e) {
|
||||
const res = await postLogin(user)
|
||||
if (res.ok) {
|
||||
let json = await res.json();
|
||||
await login(user.value.username, json);
|
||||
router.push('/');
|
||||
return;
|
||||
} else {
|
||||
res.json().then((json) => (errors.value = json));
|
||||
}
|
||||
}
|
||||
|
||||
function login(username, json) {
|
||||
async function login(username, json) {
|
||||
useAuthStore().login({username: username, token: json["token"]})
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user