-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Make current password optional when editing user? #74
Comments
Yeah, you just have to override the changeset: defmodule MyApp.Users.User do
use Ecto.Schema
use Pow.Ecto.Schema
# ...
def changeset(user_or_changeset, attrs) do
user_or_changeset
|> pow_user_id_field_changeset(attrs)
|> pow_password_changeset(attrs)
end
end |
Obviously this makes the current password irrelevant, as it should be if users can edit their information without the current password, but if you want to make it actually optional (so if used it has to be the correct password) you would need to add it as a custom changeset method: def changeset(user_or_changeset, attrs) do
user_or_changeset
|> maybe_validate_current_password(attrs)
|> pow_user_id_field_changeset(attrs)
|> pow_password_changeset(attrs)
end
defp maybe_validate_current_password(user_or_changeset, attrs) do
case current_password_entered?(attrs) do
false -> user_or_changeset
true -> pow_current_password_changeset(user_or_changeset, attrs)
end
end |
Thank you! |
axelclark
added a commit
to axelclark/ex338
that referenced
this issue
Jul 16, 2019
* Fix bug when updating user from admin page * See pow-auth/pow#74 * Closes #630
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a way to make current password optional when riding user?
The text was updated successfully, but these errors were encountered: