From the course: React: Authentication
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Authentication error handling - React.js Tutorial
From the course: React: Authentication
Authentication error handling
- [Instructor] All right, so the best practice here, which again is probably pretty obvious, is that if something goes wrong in our application, we usually want to let our users know, right? If they've put in the wrong password, when logging in for example, we want to tell them that. And if they try and view a page that they're not authorized to see, we want to tell them that as well, and so on, right? Now, that being said, we also want to avoid telling our client too much about server-side errors that occur. And one thing that this means, is that in general, we don't want to just send the client the entire error object that our server caught in the "try...catch" block. Since this can usually contain some information that hackers could use to find vulnerabilities in our site, right? Sending this error back to the client can actually provide malicious users with a little too much information about our tech stack, such as what database we're using. And in rare cases, it can even expose…