Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validations against Devise's password field cause errors due to the column being encrypted_password #155

Closed
unikitty37 opened this issue Nov 27, 2022 · 3 comments

Comments

@unikitty37
Copy link

If I set up a User model using Devise, and add validations to the password like this:

  validates :password,
            presence: true,
            # length validation is configured in the Devise initialiser
            format: {
              with: %r{\A.*[^a-zA-Z].*\z},
              message: 'must contain at least one non-letter',
            }

I get this error:

ColumnPresenceChecker fail User password column (password) is missing in
table (users) but used for presence validation

This is happening because the password is stored in the database as encrypted_password — but it's obviously not much use running the validation against the encrypted version :)

Is there a way around this apart from disabling ColumnPresenceChecker for that column? It would be useful if database_consistency could know that a password validation would be saved as encrypted_password when Devise was being used (or, more generically, if there was a way of specifying the mapping in database_consistency.yml)

@djezzzl
Copy link
Owner

djezzzl commented Nov 27, 2022

Hi @unikitty37,

Thank you for letting me know about the issue!

You can disable this particular check for you with the configuration. You can read about it in the wiki: https://github.com/djezzzl/database_consistency/wiki/configuration.

For you, it should be something like this:

User:
  password:
    ColumnPresenceChecker:
      enabled: false

Meanwhile, I will fix this annoying issue.

@djezzzl
Copy link
Owner

djezzzl commented Nov 27, 2022

I've also released 1.4.1 to avoid this issue. Please try it and let me know if that helped.

Feel free to reopen the issue if needed.

Thank you a lot and have a great day!

@djezzzl djezzzl closed this as completed Nov 27, 2022
@unikitty37
Copy link
Author

Thanks — that's fixed it! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants