Skip to content
This repository

Invalid confirmation token message not shown with simple_form #2143

Merged
merged 2 commits into from over 1 year ago

2 participants

Luis Gracia José Valim
Luis Gracia

Hi all,

When using Devise confirmable with simple_form, if a user tries to confirm with an invalid token, no meaninful error message is displayed, just the page to resend the confirmation email.

The problem, as I see it, is that the template for this view does not present the attribute :confirmation_token, and therefore #error_notification doesn't display the error, although it does output that something went wrong.

This can easily be fixed adding the full error for this attribute with:

<%= f.full_error :confirmation_token %>

Best,
Luis

Luis Gracia Show invalid confirmation token message
fixes #2143

Attribute confirmation token is not present in the simple_form template,
therefore not being displayed by #error_notification.
This fix explicitily call #full_error on :confirmation_token.
ed6f2ab
José Valim
Owner

@luisico could you please send a pull request? We have the same issue in the reset password and unlock views as well. Thansk a lot!

Luis Gracia Show invalid unlock token message
Attribute unlock token is not present in the simple_form template,
therefore not being displayed by #error_notification.
This fix explicitily call #full_error on :unlock_token.
0415564
José Valim josevalim merged commit 6c2c808 into from November 19, 2012
José Valim josevalim closed this November 19, 2012
Michał Kurek oki referenced this pull request from a commit in oki/devise November 12, 2012
Luis Gracia Show invalid confirmation token message
fixes #2143

Attribute confirmation token is not present in the simple_form template,
therefore not being displayed by #error_notification.
This fix explicitily call #full_error on :confirmation_token.
82ae2be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Nov 12, 2012
Luis Gracia Show invalid confirmation token message
fixes #2143

Attribute confirmation token is not present in the simple_form template,
therefore not being displayed by #error_notification.
This fix explicitily call #full_error on :confirmation_token.
ed6f2ab
Nov 13, 2012
Luis Gracia Show invalid unlock token message
Attribute unlock token is not present in the simple_form template,
therefore not being displayed by #error_notification.
This fix explicitily call #full_error on :unlock_token.
0415564
This page is out of date. Refresh to see the latest.
1  lib/generators/templates/simple_form_for/confirmations/new.html.erb
@@ -2,6 +2,7 @@
2 2
 
3 3
 <%= simple_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
4 4
   <%= f.error_notification %>
  5
+  <%= f.full_error :confirmation_token %>
5 6
 
6 7
   <div class="form-inputs">
7 8
     <%= f.input :email, :required => true, :autofocus => true %>
1  lib/generators/templates/simple_form_for/unlocks/new.html.erb
@@ -2,6 +2,7 @@
2 2
 
3 3
 <%= simple_form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
4 4
   <%= f.error_notification %>
  5
+  <%= f.full_error :unlock_token %>
5 6
 
6 7
   <div class="form-inputs">
7 8
     <%= f.input :email, :required => true, :autofocus => true %>
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.