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

useSignIn is not working correctly #1653

Open
4 of 5 tasks
jackyYam opened this issue Mar 25, 2024 · 4 comments
Open
4 of 5 tasks

useSignIn is not working correctly #1653

jackyYam opened this issue Mar 25, 2024 · 4 comments
Labels
question Further information is requested

Comments

@jackyYam
Copy link

Prerequisites:

Please answer the following questions for yourself before asking questions.

  • This is question only ❓
  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this is not already asked
  • I'm asking the question in the correct repository

Describe the question
A clear detailed description of what is your question.
Give correct references asked in question

I have an application built with Vite & React. I am using the useSignIn hook in order to sign In user, however it does not work. First I implemented a form to login in, expecting to redirect user to a private path using react-router and @auth-kit/react-router. However, the session is not created although signIn returns true.

Then I created a simple test with a page where I perform signIn in the useEffect like the following:

image

However, the console.log(isAuthenticated)) still outputs false. (the signIn returns true)

This is probably a really basic error, but i just couldn't find where i did wrong. So some help would be appreciated

Related issues
If your question is containing an already created issue. Tag the issue

Screenshots
If applicable, add screenshots to help explain your problem.

This is the store I am using
image

There is also nothing showing in the local storage related to this store

Please provide the following information:

  • OS: [e.g. iOS] MacOs
  • Browser [e.g. chrome, safari] Edge
  • Version [e.g. 22] Latest

License

MIT © React Auth Kit

@jackyYam jackyYam added the question Further information is requested label Mar 25, 2024
@leon11s
Copy link

leon11s commented Apr 6, 2024

I have the same problem, I don't know if it's a bug or is just me doing something wrong,

@suzimioko
Copy link

Same issue here. @jackyYam did u figure anything out?

@rchaparroplata
Copy link

I was in the same problem, and I fix it, sending valid JWT data

be sure that the JWT data that you provides has "exp" expiration time, in the payload, because after that time, the auth-kit eliminates the cookie (or the localstorage)
and it will looks like that was never written

@DarylGraves
Copy link

DarylGraves commented May 13, 2024

I am having the same issue and just wanted to share my very niche scenario just in case it helps someone:

In my situation, I created an ASP.NET API backend which came with an Identity solution out of the box. Unfortunately, after troubleshooting this evening I have found it says in on this page:

The tokens aren't standard JSON Web Tokens (JWTs). The use of custom tokens is intentional, as the built-in Identity API is meant primarily for simple scenarios. The token option isn't intended to be a full-featured identity service provider or token server, but instead an alternative to the cookie option for clients that can't use cookies.

Before this, I was able to see there was a problem by placing some breakpoints which took me into the RxTokenObject.js file. At line 52 it runs a function called getExpireDateTime() and in my situation, this would throw an exception an error because it can't parse the JWT correctly.

You can also add debug: true into your createStore() to get some logging in the browser debugging tools however in my situation it didn't seem to be printing out the exceptions I saw when I followed the debugger:

const store = createStore({
    debug: true,
    authName: "_auth",
    authType: "cookie",
    cookieDomain: window.location.hostname,
    cookieSecure: window.location.protocol === "http:",
  });

I appreciate this won't help 99% of people here but for anyone else who wrote a full-fledged backend in ASP.NET to find it doesn't work, this is why. Now I have to go and redo some of the backend again!

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

No branches or pull requests

5 participants