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

Cleanup change email form when there's a pending change #275

Merged
merged 2 commits into from
Oct 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def update_passphrase
def resend_email_change
current_user.resend_confirmation_token
if current_user.errors.empty?
redirect_to root_path, notice: "Successfully resent email change email to #{current_user.unconfirmed_email}"
redirect_to root_path, notice: "An email has been sent to #{current_user.unconfirmed_email}. Follow the link in the email to update your address."
else
redirect_to edit_user_path(current_user), alert: "Failed to send email change email"
end
Expand Down
21 changes: 11 additions & 10 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@
<h2 class="remove-top-margin remove-bottom-margin">Change your email address</h2>
<p class="text-muted bold">Changing your email address doesn’t take effect until you follow the link in a confirmation email sent to the new address.</p>
<%= form_for current_user, url: "/user", method: :put do |f| %>
<p class="form-group">
<%= f.label(:email, "Email") %>
<%= f.text_field :email, class: 'form-control input-md-6' %>
</p>
<% if f.object.unconfirmed_email.present? %>
<p>
<p class="form-group">
<%= f.label :unconfirmed_email, "You have a pending email change" %>
<%= f.text_field :unconfirmed_email, readonly: "readonly", disabled: "disabled" %>
<span class="help-inline">
<%= link_to "Resend email change", resend_email_change_user_path(f.object), :method => :put, :class => "btn btn-primary" %>
<%= link_to "Cancel email change", cancel_email_change_user_path(f.object), :method => :delete, :class => "btn btn-danger" %>
</span>
<%= f.text_field :unconfirmed_email, readonly: "readonly", disabled: "disabled", class: 'form-control input-md-6' %>
</p>
<div class="add-bottom-margin">
<%= link_to "Resend email change", resend_email_change_user_path(f.object), :method => :put, :class => "btn btn-primary add-right-margin" %>
<%= link_to "Cancel email change", cancel_email_change_user_path(f.object), :method => :delete, :class => "btn btn-danger" %>
</div>
<hr />
<% end %>
<p class="form-group">
<%= f.label(:email, "Email") %>
<%= f.text_field :email, class: 'form-control input-md-6' %>
</p>
<%= f.submit "Change email", class: "btn btn-primary" %>
<% end %>
</section>
Expand Down