Saturday 20 May 2017

Authentication with Express + React

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.

Submitted May 20, 2017 at 04:53PM by Puzz1es

No comments:

Post a Comment