Devify confirms that it does not work in the latest version

I recently upgraded from Devise 1.2 to 1.4.9, and everything seems to work except my confirmation module. Email works the same way as the whole process. But the confirmation page is always blank. It works, and it confirms the email account, but does not redirect the user and gives a 406 error. It does the same for attempts of false confirmation.

The routes seem to be working fine, I confirm what is listed in my user model and nothing else has changed.

Any ideas? Am I missing some settings or something that I need to update for 1.4.9?

UPDATE

There seems to be a problem with the url being generated. For some unknown reason, is it adding a confirmation URL with a username? and it makes him break. But I'm still not sure how to fix this.

http: // localhost: 5000 / users / confirmation.someusername? confirmation_token = R7apAPhC5c3rszvhsowp

The username in the above URL causes the process to not work.

I checked the diff between the controller in 1.2 (which works) and the new version.

1.2

# GET /resource/confirmation?confirmation_token=abcdef def show self.resource = resource_class.confirm_by_token(params[:confirmation_token]) if resource.errors.empty? set_flash_message :notice, :confirmed sign_in_and_redirect(resource_name, resource) else render_with_scope :new end end 

1.4.9

  # GET /resource/confirmation?confirmation_token=abcdef def show self.resource = resource_class.confirm_by_token(params[:confirmation_token]) if resource.errors.empty? set_flash_message(:notice, :confirmed) if is_navigational_format? sign_in(resource_name, resource) respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) } else respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render_with_scope :new } end end protected # The path used after resending confirmation instructions. def after_resending_confirmation_instructions_path_for(resource_name) new_session_path(resource_name) end # The path used after confirmation. def after_confirmation_path_for(resource_name, resource) after_sign_in_path_for(resource) end 

Error

 Started GET "/users/confirmation.sdfsdfsd?confirmation_token=vmxmx73xvM7sUfcvH9CX" for 127.0.0.1 at 2011-10-31 13:30:33 +0100 Processing by Devise::ConfirmationsController#show as Parameters: {"confirmation_token"=>"vmxmx73xvM7sUfcvH9CX"} SQL (1.1ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"users"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum User Load (1.2ms) SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = 'vmxmx73xvM7sUfcvH9CX' LIMIT 1 SQL (0.7ms) SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"users"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum Completed 406 Not Acceptable in 28ms 
+6
source share
5 answers

Take a look and see if you copied the created views; they may be outdated.

I had a similar problem getting odd user IDs in my url, devess no longer uses user_confirmation_url in favor of confirmation_url (as 1.0?, But it still worked a little longer) so that you can either remove your custom development views or update URL helper.

+5
source

Someone else pointed me in the right direction, but here is my exact solution. The problem was the development pattern templates that I copied from 1.2? It looks like they changed the link helper from user_confirmation_url() to simply confirmation_url() .

email confirmation

 <p>Welcome <%= @resource.email %>!</p> <p>You can confirm your account through the link below:</p> <p><%= link_to 'Confirm my account', user_confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p> 

new confirmation template

 <p>Welcome <%= @resource.email %>!</p> <p>You can confirm your account through the link below:</p> <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p> 
+7
source

Latest development code

 <p><%= link_to 'Confirm my account', model_confirmation_url(:confirmation_token => @model.confirmation_token) %></p> 

Version
develop-2.1.2

+1
source

In my case, I had custom views under views / development, for example. views / devise / confirmations / new.html.erb using users_confirmation_url. I don't get any more errors after I moved them to views / users and used confirm_url.

0
source

For my case (Rails 4.2 and development 3.4.1)

fixing the generated view (in app / views / devise / mailer / confirm_instructions.html.erb) required removing @resource in user_confirmation_url to just:

@token)%>

0
source

Source: https://habr.com/ru/post/900433/


All Articles