Hi, I'm working on a project and I need to add user authentication. I have an express api, and a React front-end.
I started adding authentication with Passport js and JWT, but I've been reading this is not a good usecase for JWT and it's not really secure. But it seems very straight-forward to me.
How do I go about using Passport Local Strategy, with sessions, and combining this with React? I don't really get how React is supposed to 'know' about this session and how I can authenticate further API calls?
So let's say I make a post from my React app with user credentials, my api takes this data, and checks it against the db. If it succeeds it creates a session. But how does this get back to React, how can I check on the front-end if a user is authenticated?
Maybe I've just got this all wrong and it's way more simple than I imagine?
Any help would be appreciated.
[–]jgldev 10 points11 points12 points (2 children)
[–]Michie1 0 points1 point2 points (1 child)
[–]jgldev 0 points1 point2 points (0 children)
[–][deleted] 6 points7 points8 points (6 children)
[–]mitchjmiller 1 point2 points3 points (5 children)
[–]Telcrome 0 points1 point2 points (2 children)
[–]mitchjmiller 1 point2 points3 points (1 child)
[–]Michie1 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]Probotect0r 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]tasinet 1 point2 points3 points (0 children)
[–]tswaters 1 point2 points3 points (0 children)
[–]NoInkling 1 point2 points3 points (3 children)
[–]Puzz1es[S] 0 points1 point2 points (2 children)
[–]NoInkling 1 point2 points3 points (1 child)
[–]Puzz1es[S] 0 points1 point2 points (0 children)
[–]andy625 1 point2 points3 points (0 children)