【发布时间】:2014-05-27 20:15:03
【问题描述】:
有没有办法让我忘记密码而无需使用 Gem?我已经从头开始设置了用户和我喜欢的一切。当我在我的生产应用程序中时,我输入所有内容,就好像我忘记了密码一样,它告诉我我的密码已发送,但没有显示。
Heroku 日志:
2014-04-14T01:03:32.595045+00:00 heroku[router]: at=info method=GET path=/password_resets/new host=boiling-garden-2168.herokuapp.com request_id=2b759363-24f6- 4053-87f4-81c62b98374c fwd="162.232.157.38" dyno=web.1 connect=2ms service=21ms status=304 bytes=807
2014-04-14T01:03:32.578274+00:00 app[web.1]: Started GET "/password_resets/new" for 162.232.157.38 at 2014-04-14 01:03:32 +0000
2014-04-14T01:03:32.578213+00:00 app[web.1]: Started GET "/password_resets/new" for 162.232.157.38 at 2014-04-14 01:03:32 +0000
2014-04-14T01:03:30.919303+00:00 heroku[router]: at=info method=GET path=/login host=boiling-garden-2168.herokuapp.com request_id=6b2c98d1-a2cc-4294-bdd3-a66d34f54572 fwd="162.232.157.38" dyno=web.1 connect=4ms service=29ms status=304 bytes=847
2014-04-14T01:03:42.538025+00:00 heroku[router]: at=info method=POST path=/password_resets host=boiling-garden-2168.herokuapp.com request_id=db763e58-ae0e-46e9-bf86-b930932c94c3 fwd="162.232.157.38" dyno=web.1 connect=2ms service=74ms status=302 bytes=1167
2014-04-14T01:03:42.640229+00:00 heroku[router]: at=info method=GET path=/ host=boiling-garden-2168.herokuapp.com request_id=8579ce48-075a-48c6-976e-2a5a6b9460c9 fwd="162.232.157.38" dyno=web.1 connect=3ms service=17ms status=200 bytes=5316
2014-04-14T01:03:42.520887+00:00 app[web.1]: Started POST "/password_resets" for 162.232.157.38 at 2014-04-14 01:03:42 +0000
2014-04-14T01:03:42.520899+00:00 app[web.1]: Started POST "/password_resets" for 162.232.157.38 at 2014-04-14 01:03:42 +0000
2014-04-14T01:03:42.627901+00:00 app[web.1]: Started GET "/" for 162.232.157.38 at 2014-04-14 01:03:42 +0000
2014-04-14T01:03:42.627964+00:00 app[web.1]: Started GET "/" for 162.232.157.38 at 2014-04-14 01:03:42 +0000
johns-mbp:Jetpack johncurry$
生产.rb:
config.action_mailer.default_url_options = { :host => "http://boiling-garden-2168.herokuapp.com/" }
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings =
{
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com', #you can also use google.com
:authentication => :plain,
:user_name => 'myemail@gmail.com',
:password => 'Gmailpasswordhere'
}
但是,当我使用 Localhost 时,它工作正常。
开发日志:
Started GET "/password_resets/new" for 127.0.0.1 at 2014-04-13 18:50:19 -0600
Processing by PasswordResetsController#new as HTML
Rendered password_resets/new.html.erb within layouts/application (1.2ms)
[1m[35mCategory Load (0.1ms)[0m SELECT "categories".* FROM "categories"
Rendered layouts/_navigation.html.erb (1.2ms)
Rendered layouts/_messages.html.erb (0.1ms)
Completed 200 OK in 16ms (Views: 14.6ms | ActiveRecord: 0.1ms)
Started POST "/password_resets" for 127.0.0.1 at 2014-04-13 18:50:27 -0600
Processing by PasswordResetsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"5Sy0bTXcSU8ndvQUj21dKEP1h7gVtfXtiefqrrydydA=", "email"=>"john.steven.curry@gmail.com", "commit"=>"Reset Password"}
[1m[36mUser Load (0.2ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."email" = 'john.steven.curry@gmail.com' LIMIT 1[0m
[1m[35mUser Exists (0.2ms)[0m SELECT 1 AS one FROM "users" WHERE "users"."password_reset_token" = '7ImtuiJmf7G_LksyoC8Ftg' LIMIT 1
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
[1m[35mUser Exists (0.2ms)[0m SELECT 1 AS one FROM "users" WHERE ("users"."username" = 'Curry' AND "users"."id" != 1) LIMIT 1
[1m[36mUser Exists (0.1ms)[0m [1mSELECT 1 AS one FROM "users" WHERE ("users"."email" = 'john.steven.curry@gmail.com' AND "users"."id" != 1) LIMIT 1[0m
[1m[35mSQL (19.7ms)[0m UPDATE "users" SET "password_reset_token" = ?, "password_reset_sent_at" = ?, "updated_at" = ? WHERE "users"."id" = 1 [["password_reset_token", "7ImtuiJmf7G_LksyoC8Ftg"], ["password_reset_sent_at", Mon, 14 Apr 2014 00:50:27 UTC +00:00], ["updated_at", Mon, 14 Apr 2014 00:50:27 UTC +00:00]]
[1m[36m (1.4ms)[0m [1mcommit transaction[0m
Rendered user_mailer/password_reset.text.erb (0.7ms)
Sent mail to john.steven.curry@gmail.com (11.4ms)
Date: Sun, 13 Apr 2014 18:50:27 -0600
From: john.steven.curry@gmail.com
To: john.steven.curry@gmail.com
Message-ID: <534b30d3ec249_2bda3ff2e297e6a845448@johns-mbp.mail>
Subject: Password Reset
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
To reset your password, click the URL below.
http://localhost:3000/password_resets/7ImtuiJmf7G_LksyoC8Ftg/edit
If you did not request your password to be reset, just ignore this email and your password will continue to stay the same. Have a great day!
Redirected to http://localhost:3000/
Completed 302 Found in 821ms (ActiveRecord: 21.8ms)
开发.rb
config.action_mailer.default_url_options = { :host => "localhost:3000" }
【问题讨论】:
标签: ruby-on-rails authentication heroku forgot-password