fix: always redirecting to / due to missing if statement in login page
This commit is contained in:
parent
8bfa17631c
commit
e1cce87cdb
1 changed files with 41 additions and 27 deletions
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
</form>
|
||||
<div>
|
||||
Don't have an account? <NuxtLink href="/register">Register</NuxtLink> one!
|
||||
Don't have an account? <NuxtLink :href="registerUrl">Register</NuxtLink> one!
|
||||
</div>
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
@ -34,12 +34,26 @@ const form = reactive({
|
|||
|
||||
//const authStore = useAuthStore();
|
||||
|
||||
const query = useRoute().query as Record<string, string>;
|
||||
const searchParams = new URLSearchParams(query);
|
||||
const registerUrl = `/register?${searchParams}`
|
||||
|
||||
const { login } = useAuth();
|
||||
|
||||
async function formLogin(e: Event) {
|
||||
e.preventDefault();
|
||||
console.log("Sending login data");
|
||||
try {
|
||||
await login(form.username, form.password, "Linux Laptop");
|
||||
console.log("logged in");
|
||||
if (query.redirect_to) {
|
||||
console.log("redirecting to:", query.redirect_to);
|
||||
return await navigateTo(query.redirect_to);
|
||||
}
|
||||
return await navigateTo("/");
|
||||
} catch (error) {
|
||||
console.error("Error logging in:", error);
|
||||
}
|
||||
//return navigateTo(redirectTo ? redirectTo as string : useAppConfig().baseURL as string);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue