Confirmation of rejection on first shipment

I have a Rails 4 application with Devise 3.2.2 using :confirmable, and I ran into the problem of sending invalid confirmation tokens, but only for the first time . After resending the confirmation token, the link works.

Relevant routes:

devise_for :users, skip: [:sessions, :passwords, :confirmations, :unlocks, :registrations, :invitations]
as :user do
  ...
  # joining
  get   '/register' => 'devise/registrations#new',    as: 'new_user_registration'
  post  '/register' => 'devise/registrations#create', as: 'user_registration'
  ...
end

... and mail template:

<p>Welcome <%= @email %>!</p>

<p>You can confirm your account email through the link below:</p>

<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %></p>

As far as I can tell, everything is pretty standard fare, and the fact that it only fails at the initial creation, and not in the second attempt, is rather confusing.

- Update -

When I click on the link, I get the following in my dev log:

Started GET "/account/confirm?confirmation_token=3bQP-EvYJPv74s9AMz63" for 127.0.0.1 at 2014-02-07 12:26:10 -0500
Processing by Users::ConfirmationsController#show as HTML
  Parameters: {"confirmation_token"=>"3bQP-EvYJPv74s9AMz63"}
  User Load (0.4ms)  SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = 'e191b48746f15014beb32073f08de3c7aa13a2282216f089fa71d083901b3dca' ORDER BY "users"."id" ASC LIMIT 1
  Rendered devise/shared/_links.slim (1.2ms)
  Rendered devise/confirmations/new.html.slim within layouts/devise (7.0ms)
  Rendered layouts/_jquery.slim (1.0ms)
Completed 200 OK in 32ms (Views: 23.4ms | ActiveRecord: 0.4ms)

Specified Controller:

class Users::ConfirmationsController < Devise::ConfirmationsController

  protected

  def after_confirmation_path_for(resource_name, resource)
    if signed_in?
      signed_in_root_path(resource)
    else
      new_session_path(resource_name, email: resource.email)
    end
  end

end

- Update 2 -

The following is a list of logs for the entire registration process: https://gist.github.com/jbender/bbe079c2dd3fa2d1e664

+3
2

, -, ( ) create . :

  • 5
  • 6 , , (, )
  • 9 , .
  • 11 : devise , .
  • 14 , , . , tos_accepted_at, 9. unconfirmed_email , confirm_sent_at - 1 , , 9; , , - : , , , , (), .

, ? , tos_accepted_at. - - ( ?), , , , ? , , ( , ), , confirm_sent_at .

, , INSERT, , .

, , , , 6 gist, db 9. , (. Devise:: TokenGenerator dev/toekn_generator.rb). , , , .

, resend , ( , tos_accepted_at ..)

UPDATE

, tos_accepted_at. update_attribute() after_create. , , , -, , (update_attribute , ), ( , , !). , tos_accepted_at, before_save after_create, , , , before_save, , , , after_create , , , db.

+6

, , .
, - . # . , _token .

:

confirm_token ?

-1

All Articles