Skip to content

Can't log in if the email contains a dot #20

Description

@AlbertVilaCalvo

If you sign up with an email with a dot (eg john.cobra@example.com), the dot is removed in usersController.validate before being saved to the database.

If you later try to log in with that email with a dot, since the email does not get sanitized in usersController.validate and thus the dot is not removed, the input email and the database email don't match, so you can't log in. The error flash message just says "Failed to login.".

If you add some code in usersController.authenticate you can see that the info param in passport.authenticate callback is "[IncorrectUsernameError]: Password or username is incorrect".

One option to fix this is to run the express-validator code in /users/login like is done in /users/create:

router.post(
  '/users/login',
  usersController.validate, // <-- add this
  usersController.authenticate
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions