设计确认链接不起作用

汤姆·麦克斯韦

真的很烦这里。在我的Rails应用程序中,所有电子邮件都是通过Mandrill通过SMTP发送的;该应用程序本身托管在Heroku上。就Devise gem而言,一切似乎都可以正常工作-用户可以注册,登录等。但是,电子邮件中包含的确认链接无效。

看起来像这样:

http://anymarket.co/users/confirmation?confirmation_token=1fde79fe312eec0efc733e77f946aba5d7b227cbdfeb54e429f9a0e6f369a5cd

当我单击链接并检查日志时,似乎发生的唯一事情是将用户定向到站点的根目录。不会加载ConfirmationsController#show操作。

我真的不确定是什么问题。在routes.rb文件的开头,我有以下内容:

devise_for :users, :controllers => { :registrations => 'registrations' }
default_url_options :host => "anymarket.co"

我用以下方法覆盖了RegistrationsController:

class RegistrationsController < Devise::RegistrationsController
  before_filter :authenticate_user!, :except => [:after_inactive_sign_up_path_for]

    def new 
        respond_to do |format|
            format.js
            format.html
        end
    end

    def create
    build_resource(sign_up_params)

    resource_saved = resource.save
    yield resource if block_given?
    if resource_saved
      if resource.active_for_authentication?
                set_flash_message :onboard, :signed_up if is_flashing_format?
        sign_up(resource_name, resource)
        respond_with resource, location: after_sign_up_path_for(resource)
      else
                set_flash_message :onboard, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
        expire_data_after_sign_in!
        respond_with resource, location: after_inactive_sign_up_path_for(resource)
      end
    else
      clean_up_passwords resource
      @validatable = devise_mapping.validatable?
      if @validatable
        @minimum_password_length = resource_class.password_length.min
      end
      respond_with resource
    end
  end

  def after_inactive_sign_up_path_for(user)
        respond_to do |format|
             format.html {render :action => "/"}
    end
  end

    private

  def sign_up_params
    params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :avatar, :school, :provider, :uid)
  end

  def account_update_params 
    params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :current_password, :avatar, :braintree_customer_id)
  end

end

任何想法我在这里做错了吗?

编辑:耙路线的结果 grep确认

user_confirmation POST   /users/confirmation(.:format)              devise/confirmations#create                                                                  
    new_user_confirmation GET    /users/confirmation/new(.:format)          devise/confirmations#new                                                                     
                          GET    /users/confirmation(.:format)              devise/confirmations#show    

跟踪日志,这是新用户单击确认链接时发生的情况

Started GET "/" for 98.245.3.223 at 2014-09-10 07:29:36 +0000                                                               
2014-09-10T07:29:36.706263+00:00 app[web.1]:   Rendered home/index.html.erb within layouts/application (104.6ms)                                                         
2014-09-10T07:29:36.709496+00:00 app[web.1]: Completed 200 OK in 112ms (Views: 96.9ms | ActiveRecord: 12.6ms)                                                            
2014-09-10T07:29:36.597154+00:00 app[web.1]: Processing by HomeController#index as HTML                                                                                  
2014-09-10T07:29:36.708971+00:00 app[web.1]:   Rendered layouts/_no_cc_alert.html.erb (0.2ms)                                                                            
2014-09-10T07:29:36.718357+00:00 heroku[router]: at=info method=GET path="/" host=www.anymarket.co request_id=a42fa3d1-f7a2-4871-92d7-14278f93cae7 fwd="98.245.3.223" dyn
o=web.1 connect=2ms service=126ms status=200 bytes=1036  
伊万·米西奇(Ivan Misic)

您的ssl配置错误

如果您想发送链接:http : //anymarket.co/users/confirmation?confirmation_token=1fde79fe312eec0efc733e77f946aba5d7b227cbdfeb54e429f9a0e6f369a5cd

有两个问题,首先是获得纯HTTP端口80未加密的协议,但是您配置了ssl以便将其重定向到https协议。第二个是您将www.anymarket.co配置为ssl终结点而不是anymarket.co,因为您正在子域上获得索引页面。您可以使用curl进行测试:

curl -kvI https://anymarket.co

curl -kvI https://www.anymarket.co

换句话说,您邮件中的链接应该像这样

https://www.anymarket.co/users/confirmation?confirmation_token=1fde79fe312eec0efc733e77f946aba5d7b227cbdfeb54e429f9a0e6f369a5cd

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章