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

Logging in always says "*Invalid email or password." #96

Closed ar065 closed 2 years ago

ar065 commented 2 years ago

This is also with a fresh clone of the project with all correct environmental variables.

flaviuse commented 2 years ago

You should check the database and see if the user has been created properly after registration, if you got a validation email and you validated the account that should be the case. I could not reproduce with a fresh install. The code that handles login can be found in here : https://github.com/flaviuse/mern-authentication/blob/master/server/routes/auth.js#L30

ar065 commented 2 years ago

Hmm.. What node version do you happen to be using? The user appears to be created just fine and the user is verified.

flaviuse commented 2 years ago

Are you using the docker compose setup ? The node version is defined in the the docker image, it is version 14.16

ar065 commented 2 years ago

Are you using the docker compose setup ? The node version is defined in the the docker image, it is version 14.16

Yes, I am. I forgot docker specifies the node version 😂. Im currenting using docker desktop on windows, does that matter?

flaviuse commented 2 years ago

I use docker desktop as well on windows, it should not change anything the code is running in the same environment container. Are you trying to connect with the username or email of the account you created ? Connection with email will not work with the frontend even if the API support it. You can add logging in the code to check what is happening: (winston.info) auth route That will log in the server: log If you are using the username to connect then I don't know what it can be aside of bad password/username :/ The registration process worked so the DB connection and API are working. I can be a bug that I am not aware.

Delete your containers/images from docker, create a new user and try again, I use https://temp-mail.org/ to test with temporary emails

ar065 commented 2 years ago

I use docker desktop as well on windows, it should not change anything the code is running in the same environment container. Are you trying to connect with the username or email of the account you created ? Connection with email will not work with the frontend even if the API support it. You can add logging in the code to check what is happening: (winston.info) auth route That will log in the server: log

Thank you. I shall try this in a few minutes. I also tried logging in with username and email just to check.