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

Fix validation failures and error page display #16399

Merged
merged 4 commits into from Jul 13, 2017

Conversation

ewjordan
Copy link
Contributor

Enables validation of email/parent_email presence when upgrading an account, as well as turning on username uniqueness validation.

Also reloads the user model when the upgrade action fails, so that the error page displays based on the pre-upgrade values (otherwise it ends up displaying in an odd mixed state, depending on which fields have been entered).

@ewjordan ewjordan requested a review from aoby July 13, 2017 19:03
@@ -59,6 +59,7 @@ def upgrade
successfully_updated = can_update && current_user.update(update_params(params_to_pass))
has_email = current_user.parent_email.blank? && current_user.hashed_email.present?
success_message_kind = has_email ? :personal_login_created_email : :personal_login_created_username
user.reload unless successfully_updated # if update fails, roll back user model so error page renders correctly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the error page not inspect user.errors? Reloading user will clear those.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't appear to be the case, the errors show up correctly with this change:

screen shot 2017-07-13 at 1 17 23 pm

What the user typed in gets cleared out, which is not ideal, but in this context (just the upgrade call) it's not terrible because most of that information is either secret confirmation or password-related, so doesn't auto-fill anyways.

@ewjordan ewjordan merged commit bb69c86 into staging Jul 13, 2017
@ewjordan ewjordan deleted the take-your-account-bugfixes branch July 13, 2017 21:18
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

Successfully merging this pull request may close these issues.

None yet

2 participants