How Do Developers Handle Authentication? - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › How Do Developers Handle Authentication? (532 Views)
| How Do Developers Handle Authentication? by SqueezedPant(op): 1:38pm On Aug 08, 2023*. Modified: 2:24pm On Aug 08, 2023 |
I am currently making a file storage system for organizations as a side project , using next auth for the authentication(I don’t know how to roll my auth). Now the issue i am having is whenever i refresh the page , the session disappears for some seconds. Now this is where the problem is , as the session disappears , some routes are protected in the middleware.ts file. So immediately , the routes get locked. So how can i save session so that maybe if there is a 1 minute network blackout , i won’t get locked out immediately. I have ruled the idea of saving in local because if the network gets switched off completely , it would still be saved in there. And you cannot revalidate local storage based on “network timeout” . I would appreciate your help on this @qtguru please i would need your expert opinion here |
| Re: How Do Developers Handle Authentication? by eazycash: 4:03pm On Aug 08, 2023 |
you didn't mention the technology your using to implement the authentication.how do you someone will be in the know how to be of help to you. |
| Re: How Do Developers Handle Authentication? by SqueezedPant(op): 9:45pm On Aug 08, 2023 |
eazycash:NextAuth , Next Js 13 app directory |
| Re: How Do Developers Handle Authentication? by potnovus(m): 10:00am On Aug 10, 2023 |
I'll try to give you general guidance here since this is an authentication problem, irrespective of technology used; also because I'm not necessarily a nextjs engineer. However, I'm aware that NextAuth uses JSON Web Tokens (JWTs) for managing user-sessions, with the option to persist session info in a database. Without knowing the specifics of your implementation and authentication needs, I can only advise that you pay attention to the expiration-time (Time To Live) set for the generated JWTs after you authenticate a user for the first time. When you increase the TTL of your tokens, you allow the user session to live a bit longer. That been said, if as part of your authentication flow, you maintain both a "refresh" and "access" token, then, you may have to decide which of the tokens' TTL you want to increase to satisfy the authentication need of your solution. I hope this helps. |
| Re: How Do Developers Handle Authentication? by Deicide: 1:03am On Aug 13, 2023 |
NextAuth handles that automatically, check if maybe you not doing something correctly. |
How Do You Handle Authentication In Your Projects? What's The Industry Standard? • Why Do Developers Like Using Tiny Fonts • Why Do Developers Think Jquery Is Obsolete? • 2 • 3 • 4
. • Hi Guys Please Rate My New (news App) And Share.. • How To Make A Cmd Movement Game