We will be using hooks and context. We will only use the basic concept, you don't need to go too far into this subject for this use case.
...
For further actions, you may consider blocking this person and/or reporting abuse
I'm not sure storing the credentials locally is the way to go. Also the redirection is easily bypassable by setting an arbitrary auth.data.
I agree. I would suggest using Auth0. They have a good example on the Auth0 website.
We would not save the user credentials in the browser local storage, but rather just the token received after authentication. As I said, the tutorial do not cover the backend portion of it but rather saving the token and blocking access to "authenticated" routes. You could use it to implement Auth0, which could actually be a nice continuation of my tutorial! :)
EDIT: I agree my article does not emphasize this enough. I updated the article to add a disclaimer to save the token and not the actual credentials. Thank you!
Hi, firstly it's a great article. Implementing the back end token code was beyond the scope in my opinion. What it demonstrates is exactly what you said in your reply. And the private route implementation is good as well.
Awesome! I'm currently learning React, this will help 🙂
In AuthContext.js this bit is causing an error for me:
const setAuthData = (data) => {
setAuth({data: data});
};
It is saying
Argument types do not match parameters
. So I addedloading: false
to the object passed in tosetAuth
and the error went away.Great stuff! 👏🏾
However may I present something to you?
Lets say I was your boss and I said "...right, just what we need. What do we need to do, to get this into production?..."
What would your response be?
Thanks for this tutorial! It really helped me and my team with a task 😁
Thank you miss, your tutorial was very helpful to me.
Nice one from you dear, the article was well-detailed and really helpful...
The best react authentication i've found on internet. You're awesome !!!
Great article. It would be great to see this extended with JWT and a database. Or using Auth0.
Great.. Help!!! Thanks for sharing!!
Nice one!💚