gpt4 book ai didi

ruby-on-rails - 设计确认链接无效

转载 作者:数据小太阳 更新时间:2023-10-29 08:46:43 24 4
gpt4 key购买 nike

这里真的很生气。在我的 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

最佳答案

你的ssl配置有误

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

有两个问题,首先你得到了纯http 80端口未加密协议(protocol),但是你配置了ssl所以你被重定向到https协议(protocol)。第二个是您将 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

关于ruby-on-rails - 设计确认链接无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25759385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com