refactor(pages): update login page

navigate to the home page after successful login
This commit is contained in:
parent d38c217a58
commit 6a35c4affc
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -10,6 +10,7 @@
unauthenticatedOnly: true, unauthenticatedOnly: true,
navigateAuthenticatedTo: "/", navigateAuthenticatedTo: "/",
}, },
middleware: ["auth"],
}); });
const formState = reactive<FormState>({ const formState = reactive<FormState>({
@ -23,6 +24,10 @@
let reso: any; let reso: any;
try { try {
reso = await signIn(values); reso = await signIn(values);
await navigateTo({
path: "/",
});
} catch (e: any) { } catch (e: any) {
if (e.data) { if (e.data) {
notification["error"]({ notification["error"]({
@ -30,24 +35,20 @@
}); });
} }
} }
await navigateTo({
path: "/",
});
}; };
</script> </script>
<template> <template>
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" autocomplete="off" :colon="false" layout="vertical" @finish="onFinish"> <a-form :model="formState" name="basic" :label-col="{ span: 8 }" autocomplete="off" :colon="false" layout="vertical" @finish="onFinish">
<a-form-item label="Username" name="username" :rules="[{ required: true, message: 'Username required!' }]"> <a-form-item label="Username" name="username" :rules="[{ required: true, message: 'Username required!' }]">
<a-input v-model:value="formState.username" /> <a-input data-testid="login.username" v-model:value="formState.username" />
</a-form-item> </a-form-item>
<a-form-item :colon="false" label="Password" name="password" :rules="[{ required: true, message: 'Password required!' }]"> <a-form-item :colon="false" label="Password" name="password" :rules="[{ required: true, message: 'Password required!' }]">
<a-input-password v-model:value="formState.password" /> <a-input-password data-testid="login.password" v-model:value="formState.password" />
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-row :justify="'center'" :align="'middle'"> <a-row :justify="'center'" :align="'middle'">
<a-col> <a-col>
<a-button type="primary" html-type="submit">Log in</a-button> <a-button data-testid="login.submit" type="primary" html-type="submit">Log in</a-button>
</a-col> </a-col>
</a-row> </a-row>
</a-form-item> </a-form-item>