graphql_devise icon indicating copy to clipboard operation
graphql_devise copied to clipboard

Best way to require password when updating user model (ie user's email)

Open keithmgould opened this issue 5 years ago • 1 comments

Hi!

I'd like to ensure the user sends up a valid password when updating their email. I've followed the reconfirmation section of your README, but that suggests (requires?) that we use user.update_with_email (as seen in dummy project mutation), but I'd like to use user.update_with_password since that offers the validation I need.

Wondering if you have any solutions to this?

Thank you!

PS: Currently using user.valid_password? before user.update_with_email, which works fine. Happy to close this if you think its the best way.

keithmgould avatar Jan 27 '21 15:01 keithmgould

Hey @keithmgould! What you are doing is definitively the best way to do it for the current version of the gem. This is something I did think about when implementing the update_with_email method. So you are talking about a method that would do both things, right? Something like update_with_email_and_password. That's probably the way I'd go so the dev can choose from those 3 depending on what they are trying to implement.

So, if that's what you mean, lets keep this one open as I do think it'd be a nice addition to the gem. We'll work on it as soon as we can, but as always, anyone is welcome to create a PR that solves this 😉

mcelicalderon avatar Jan 27 '21 23:01 mcelicalderon