Can someone tell me the best way to go about this problem? My site will have one admin user (there will be NO OTHER users) to be able to CRUD data on the /admin route after the admin logs in. I found this tutorial: https://tylermcginnis.com/react-router-protected-routes-authentication/
but it gave me no luck as I don’t understand the point of the fakeAuth function. Wouldn’t I need to wrap it all into a cookie/JWT? I know I need backend auth somehow and I have the username and pass stored in an environment variable. Just very curious as to how to get a basic backend auth for the admin user, then use react router to redirect after the auth is verified. Any help on this would be much appreciated.
Cookie/jwt &co. are the stuff to imagine to be into fakeAuth
That tutorial explain how to render one component or redirect to another route ( hence display another component ) based on the value of a property^^ ( in that case the isAuthenticated property )
The backend auth is what gives you the value of isAuthenticated prop, the two topic are not related^^
Here another tut with all this stuff: Medium : Handle auth with node and passport
Tut was randomly taken honestly, it just had all you need to build an auth flow on an express app
That said i see not much difference on set up an auth flow for one single person and a whole pirate crew^^
I mean, at the end of the story that single person must insert some kind of key / password / fingerprint / whatever to authenticate himself right? So why other people cannot do the same with their own credentials?
Maybe the only big diff is that you do not need a db to hold the data, apart that i can’t think of some other meaningful difference ( i am not a security ninja btw, just my impressions^^ )
Protected routes are an important part of any web application. In this post we’ll break down the “Redirects (Auth)” example on the React Router documentation to learn how to create authenticated routes (routes that only certain users can access based on their authentication status) using React Router.