flaviuse / mern-authentication

MERN stack authentication boilerplate: password reset, email verification, server sessions, redux, typescript, hooks and docker for dev and prod.
https://mern-auth-client.herokuapp.com/login
MIT License
439 stars 95 forks source link

updated react setServerError to show 401 unverified errors in the app #10

Closed ujjwal-kr closed 4 years ago

ujjwal-kr commented 4 years ago

if a user registers and the app not verify the account, and then tries to login, the server throws an 401 unauthorized(401) error,, but the react client does not reflect . This fixes it by adding a check in the login component which listens to 401 errors

flaviuse commented 4 years ago

Hi, I tested the app, and if a user registers and does not verify the account, and then tries to login, the server throws an 401 unauthorized(401) error,, but the react client does not reflect it 😞... But this PR should to fix it 😸, as this adds a check in the login component which listens to 401 errors as well! Have a great day

Hey, I am reviewing all the endpoint errors to check if there are the same type of issues on other endpoints/views. And updating some HTTP code/errors along the way. I'll get back to your PR once it's done.

ujjwal-kr commented 4 years ago

okay, cool !

flaviuse commented 4 years ago

okay, cool !

Ok so I have checked the errors on the server and changed some HTTP codes. Check this PR: #11 I have also changed some messages avoiding giving too much details in the client for errors 500 codes. We can maybe simplify it to handle Message errors in all the views without taking into account error codes at all in the client, like this : if (error.response) { setServerError(error.response.data.message)} That way the user has always some feedback.

Another thing, I am not sure about the else {return;}. I have not used it for other views, what do you think about removing it for consistency ?

If its ok for you I'll merge #11 so you can do the modification for this PR.

ujjwal-kr commented 4 years ago

okay well I am modifying my PR

ujjwal-kr commented 4 years ago

do you need this modification in any other place?

flaviuse commented 4 years ago

do you need this modification in any other place?

yes there are handlers to modify with the new behaviour in ConfirmPage.jsx, LoginForgot.jsx, LoginResetPassword.jsx and Register.jsx (3 handlers to modify here) : image

ujjwal-kr commented 4 years ago

okay lemme check it out

ujjwal-kr commented 4 years ago

flaviuse commented 4 years ago

That's perfect! Thanks for the contribution :partying_face: .

flaviuse commented 4 years ago

Yo, thanks.. hey wanna know a fact ?

I am just 16 yr old, and you look like a professional developer,, It was great to work with you and I will be grateful if you take me in collab with more awesome stuff 😸

Awesome :) Keep contributing in open source (big projects if you can) it will definitely help you improve 👍 I'll notify you if I start new stuff !

ujjwal-kr commented 4 years ago

thats an issue actually.. i dont know how to approach large projects 😅

flaviuse commented 4 years ago

thats an issue actually.. i dont know how to approach large projects 😅

Have a look here : https://css-tricks.com/how-to-contribute-to-an-open-source-project/. For large project, you have to focus on small parts firsts, it will take time anyway