Fix router initialization in eventhandler
All checks were successful
continuous-integration/drone/push Build is passing
ci/woodpecker/push/woodpecker Pipeline was successful

useRouter has to be called in setup or returns undefined otherwise.
See https://github.com/vuejs/vue-router/issues/3379
This commit is contained in:
2022-02-21 21:40:36 +00:00
parent 4085868cd7
commit e9d4ed1b3e
2 changed files with 11 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import { useSessionStore } from "../stores/session";
const error = ref("");
const login = ref({ user: "", password: "" });
const router = useRouter(); // has to be called in setup
onMounted(() => {
useSessionStore().setTitle("Login");
@ -15,7 +16,8 @@ function formSubmit(e: MouseEvent) {
useSessionStore().login(login.value)
.then(x => {
error.value = "";
useRouter().replace("/dashboard");
router.replace("/dashboard");
return x;
})
.catch(x => error.value = "The entered credentials are invalid!");