dev #1
1 changed files with 41 additions and 27 deletions
|
@ -16,7 +16,7 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div>
|
<div>
|
||||||
Don't have an account? <NuxtLink href="/register">Register</NuxtLink> one!
|
Don't have an account? <NuxtLink :href="registerUrl">Register</NuxtLink> one!
|
||||||
</div>
|
</div>
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
|
@ -34,12 +34,26 @@ const form = reactive({
|
||||||
|
|
||||||
//const authStore = useAuthStore();
|
//const authStore = useAuthStore();
|
||||||
|
|
||||||
|
const query = useRoute().query as Record<string, string>;
|
||||||
|
const searchParams = new URLSearchParams(query);
|
||||||
|
const registerUrl = `/register?${searchParams}`
|
||||||
|
|
||||||
const { login } = useAuth();
|
const { login } = useAuth();
|
||||||
|
|
||||||
async function formLogin(e: Event) {
|
async function formLogin(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("Sending login data");
|
console.log("Sending login data");
|
||||||
|
try {
|
||||||
await login(form.username, form.password, "Linux Laptop");
|
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);
|
//return navigateTo(redirectTo ? redirectTo as string : useAppConfig().baseURL as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue