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

user.update_with_password ignores password_confirmation #5674

Closed
anujaware opened this issue Feb 19, 2024 · 2 comments
Closed

user.update_with_password ignores password_confirmation #5674

anujaware opened this issue Feb 19, 2024 · 2 comments

Comments

@anujaware
Copy link

It doesn't seems to be resolved or may reccured (previous issue reference).

I am facing the same issue. While user.update_with_password, if I pass current_password, password and password_confirmation it compares current_password and password but ignores password_confirmation
I have enabled validatable in user model.

3.2.0 :011 > user.update_with_password(password: '12345678', password_confirmation: '1234567', current_password: 'dl12347890')
  TRANSACTION (0.1ms)  BEGIN
  User Update (0.5ms)  UPDATE "users" SET "encrypted_password" = $1, "updated_at" = $2 WHERE "users"."id" = $3  [["encrypted_password", "[FILTERED]"], ["updated_at", "2024-02-19 02:22:45.629054"], ["id", 14]]
  TRANSACTION (6.6ms)  COMMIT
 => true 
@aruprakshit
Copy link

@anujaware Show your user model please and Rails version, Devise verstion too.

@nashby
Copy link
Collaborator

nashby commented Nov 26, 2024

Closing this since it seems to work fine:

devise-test(dev)> u.update_with_password(password: '123456', password_confirmation: '1234567', current_password: '654321')
=> false
devise-test(dev)> u.errors
=> #<ActiveModel::Errors [#<ActiveModel::Error attribute=password_confirmation, type=confirmation, options={:if=>:password_required?, :attribute=>"Password"}>]>

@nashby nashby closed this as completed Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants