这在过去并不是一个问题,但出于某种原因,当我点击我的Rails应用程序的Devise确认电子邮件中的链接时,它会转到该网站,但不会确认该帐户。
我的应用程序托管在Heroku上,我通过Mandrill发送电子邮件。我昨天刚把我的应用程序切换到HTTPS,所以也许可能是这样吗?这是confirm_instructions.html.erb的模板本身:
<h3>Welcome to AnyMarket!</h3>
<p>Please click to link below to confirm your account and get started:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
在Production.rb中:
config.action_mailer.default_url_options = { :host => 'anymarket.co'}
config.action_mailer.smtp_settings = {
:port => '587',
:address => 'smtp.mandrillapp.com',
:user_name => ENV['MANDRILL_USERNAME'],
:password => ENV['MANDRILL_APIKEY'],
:domain => 'heroku.com',
:authentication => :plain
}
config.action_mailer.delivery_method = :smtp
在user.rb中:
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
我还重写了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
也许它可能与我在registrationscontroller中的创建动作有关?我真的不确定。电子邮件发送查找和确认令牌在加载时会短暂显示在URL中。
以下是我在注册表单上点击提交后得到的日志:
Started POST "/users" for 98.245.3.223 at 2014-09-10 05:19:43 +0000
2014-09-10T05:19:43.542630+00:00 app[web.1]:
2014-09-10T05:19:43.542639+00:00 app[web.1]: Sent mail to sfds@anymarket.co (82.0ms)
2014-09-10T05:19:43.564646+00:00 app[web.1]: Redirected to https://www.anymarket.co/
2014-09-10T05:19:43.564786+00:00 app[web.1]: Completed 302 Found in 214ms (ActiveRecord: 21.2ms)
2014-09-10T05:19:43.350891+00:00 app[web.1]: Processing by RegistrationsController#create as HTML
2014-09-10T05:19:43.350917+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"TsjutBJu4kLW3bdlszJp0gAo1snW/GG47lNsvzC8LJE=", "user"=>{"first_name"=>"TF
DSFD", "last_name"=>"FDSDSF", "email"=>"SFDS@anymarket.co", "password"=>"[FILTERED]"}, "commit"=>"Join AnyMarket"}
2014-09-10T05:19:43.458693+00:00 app[web.1]: Rendered devise/mailer/confirmation_instructions.html.erb (0.9ms)
2014-09-10T05:19:43.564834+00:00 heroku[router]: at=info method=POST path="/users" host=www.anymarket.co request_id=2b72d511-c72a-4091-8f7b-c6a96be14b9d fwd="98.245.3.22
3" dyno=web.1 connect=1ms service=226ms status=302 bytes=1272
2014-09-10T05:19:43.663161+00:00 app[web.1]: Started GET "/" for 98.245.3.223 at 2014-09-10 05:19:43 +0000
2014-09-10T05:19:43.822546+00:00 app[web.1]: Rendered home/index.html.erb within layouts/application (149.0ms)
2014-09-10T05:19:43.826212+00:00 app[web.1]: Completed 200 OK in 158ms (Views: 122.7ms | ActiveRecord: 32.9ms)
2014-09-10T05:19:43.667650+00:00 app[web.1]: Processing by HomeController#index as HTML
2014-09-10T05:19:43.825590+00:00 app[web.1]: Rendered layouts/_no_cc_alert.html.erb (0.3ms)
2014-09-10T05:19:43.827152+00:00 heroku[router]: at=info method=GET path="/" host=www.anymarket.co request_id=4146422c-eee3-4718-bcd3-ac57a3270cd9 fwd="98.245.3.223" dyn
o=web.1 connect=1ms service=173ms status=200 bytes=1324
然后,一旦我点击确认链接:
2014-09-10T05:19:43.827152+00:00 heroku[router]: at=info method=GET path="/" host=www.anymarket.co request_id=4146422c-eee3-4718-bcd3-ac57a3270cd9 fwd="98.245.3.223" dyn
o=web.1 connect=1ms service=173ms status=200 bytes=1324
2014-09-10T05:20:09.309563+00:00 heroku[router]: at=info method=HEAD path="/" host=www.anymarket.co request_id=1e871265-fe33-47a4-b141-e107fb516db3 fwd="54.247.188.179"
dyno=web.1 connect=1ms service=5ms status=301 bytes=432
2014-09-10T05:20:47.054014+00:00 heroku[router]: at=info method=HEAD path="/" host=www.anymarket.co request_id=1b8ff5d7-4aa3-4a20-a16d-79531c4bf362 fwd="54.248.250.232"
dyno=web.1 connect=0ms service=4ms status=301 bytes=432
2014-09-10T05:20:54.673266+00:00 heroku[router]: at=info method=HEAD path="/" host=www.anymarket.co request_id=e728d60a-cb16-4de0-a093-44c7dcad1048 fwd="184.73.237.85" d
yno=web.1 connect=3ms service=3ms status=301 bytes=431
2014-09-10T05:21:09.238154+00:00 heroku[router]: at=info method=GET path="/" host=www.anymarket.co request_id=337c509a-4b15-45b8-a95e-5d9da765a594 fwd="98.245.3.223" dyn
o=web.1 connect=1ms service=102ms status=200 bytes=1292
2014-09-10T05:21:09.147871+00:00 app[web.1]: Processing by HomeController#index as HTML
2014-09-10T05:21:09.235638+00:00 app[web.1]: Rendered layouts/_no_cc_alert.html.erb (0.3ms)
2014-09-10T05:21:09.142466+00:00 app[web.1]: Started GET "/" for 98.245.3.223 at 2014-09-10 05:21:09 +0000
2014-09-10T05:21:09.232445+00:00 app[web.1]: Rendered home/index.html.erb within layouts/application (77.5ms)
2014-09-10T05:21:09.236220+00:00 app[web.1]: Completed 200 OK in 88ms (Views: 47.6ms | ActiveRecord: 37.2ms)
2014-09-10T05:21:39.043506+00:00 heroku[router]: at=info method=HEAD path="/" host=www.anymarket.co request_id=47a3486a-a83c-4886-a774-0819d7652201 fwd="50.31.164.139" d
yno=web.1 connect=2ms service=5ms status=301 bytes=431