Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth/local example redirectTo is not working properly #23

Open
asonnleitner opened this issue Mar 9, 2023 · 3 comments
Open

auth/local example redirectTo is not working properly #23

asonnleitner opened this issue Mar 9, 2023 · 3 comments

Comments

@asonnleitner
Copy link

When testing the auth/local example I noticed that the redirectTo is not working properly, I
figured that the useAuth().redirectTo value gets cleared before being used.

  await $fetch("/api/auth/login", {
    method: "POST",
    body: {
      email: email,
      password: password,
    },
  });
  useAuth().redirectTo.value = null; // <-- this line
  await useAuth().updateSession();
  await navigateTo(useAuth().redirectTo.value || "/");

So the null value could maybe be set after the navigateTo call, or can possibly omitted at all, as it gets set from the auth middleware anyway.

Else, great example, thanks for sharing!

@pi0
Copy link
Member

pi0 commented Mar 10, 2023

Hi. Do you mind to open a PR for fix?

@asonnleitner
Copy link
Author

Sure! Can do, will create a PR straight away on Monday

@marr
Copy link

marr commented May 28, 2023

I have also attempted to fix this with #27
It covers the case of redirecting properly when using server (hard) page load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants