質問編集履歴
4
タイトルをポイントだけに絞りました。試したことに追記しました。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
パスワード再設定のurlが、Password Rsetフォームにリンクしないで、Homeへいくのですが・・。
|
body
CHANGED
@@ -1,50 +1,31 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
Railsチュートリアルの12章を進めている中で、パスワード再設定のメールアドレスをサーバーでコピペし、ブラウザをリロードするのですが、
|
3
3
|
root_url(トップページ)に戻ってしまいます。
|
4
|
-
Reset passwordのページに行きません。というより、コードはもちろん記述済みなのですが、この再設定のフォームに繋が
|
4
|
+
Reset passwordのページに行きません。というより、コードはもちろん記述済みなのですが、この再設定のフォームに繋がらずloop状態です。
|
5
5
|
Forgot passwordのフォームは問題なく現れます。
|
6
6
|
いろんなサイトを同様の事例が無いか探してみたり、チュートリアルページを何度も見直してみたのですがコードの記述に問題がなく
|
7
|
-
何がどうなっているのかわからない状態で
|
7
|
+
何がどうなっているのかわからない状態で1週間たってしまいました・・。
|
8
|
-
|
8
|
+
一人では解決できず困っております。アドバイス頂けますと大変有難いです。
|
9
|
+
よろしくお願いします。
|
9
10
|
|
10
11
|
### 発生している問題・エラーメッセージ
|
11
12
|
|
12
13
|
```
|
13
14
|
エラーメッセージは、無いのですが
|
14
15
|
ローカルで、パスワード再設定フォームからアドレスを入れるとサーバーに再設定フォーム用アドレスが生成されるはずが、
|
15
|
-
root_urlになってしまい、
|
16
|
+
root_urlになってしまい、ループ状態でReset Passwordフォームに繋がりません。
|
16
17
|
```
|
17
18
|
|
18
19
|
### 該当のソースコード
|
19
20
|
|
20
21
|
```ここに言語名を入力
|
21
|
-
以下はソースではなくプレビュー画面のテキストです。
|
22
|
-
|
23
|
-
From:
|
24
|
-
noreply@example.com
|
25
|
-
To:
|
26
|
-
eaxmple@railstutorial.org
|
27
|
-
Date:
|
28
|
-
Wed, 05 Feb 2020 13:00:15 +0000
|
29
|
-
Subject:
|
30
|
-
Password reset
|
31
|
-
|
32
|
-
|
33
|
-
Password reset
|
34
|
-
To reset your password click the link below:
|
35
|
-
|
36
|
-
Reset password
|
37
|
-
This link will expire in two hours.
|
38
|
-
|
39
|
-
If you did not request your password to be reset, please ignore this email and your password will stay as it is.
|
40
|
-
|
41
|
-
|
42
22
|
```
|
43
23
|
|
44
24
|
### 試したこと
|
45
25
|
|
46
|
-
Forgot passwordメールを送って出てきたサーバーログが以下なのですが、Homeのアドレスに必ずなっていて、Reset passwordの
|
26
|
+
Forgot passwordメールを送って出てきたサーバーログが以下なのですが、Homeのアドレスに必ずなってしまっていて、Reset passwordの
|
47
27
|
フォームに繋がりません。いろいろ探したコードチェックもしたのですが、何も落ち度がないのですが、なぜこんな現象が起こるのでしょうか・・。
|
28
|
+
11章の内容をgit mergeした際に一部コンフリクトを起こしたので、bit cleanをしたのですが、これが影響しているのでしょうか。
|
48
29
|
|
49
30
|
Started POST "/password_resets" for 127.0.0.1 at 2020-02-03 23:17:51 +0900
|
50
31
|
Processing by PasswordResetsController#create as HTML
|
3
更新しました。よろしくお願いします。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Railsチュートリアル第12章で、
|
1
|
+
Railsチュートリアル第12章で、実装した筈のPassword Rsetフォームが現れない。
|
body
CHANGED
@@ -1,92 +1,44 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
|
-
Railsチュートリアルの12章を進めている中で、パスワード再設定のメールアドレスを
|
2
|
+
Railsチュートリアルの12章を進めている中で、パスワード再設定のメールアドレスをサーバーでコピペし、ブラウザをリロードするのですが、
|
3
|
+
root_url(トップページ)に戻ってしまいます。
|
3
|
-
Reset passwordのページに行きません。というより、コードはもちろん記述済みなのですが、この再設定のフォーム
|
4
|
+
Reset passwordのページに行きません。というより、コードはもちろん記述済みなのですが、この再設定のフォームに繋がりません。
|
4
|
-
Forgot passwordのフォームは問題なく
|
5
|
+
Forgot passwordのフォームは問題なく現れます。
|
5
|
-
|
6
|
+
いろんなサイトを同様の事例が無いか探してみたり、チュートリアルページを何度も見直してみたのですがコードの記述に問題がなく
|
7
|
+
何がどうなっているのかわからない状態で三日ほど迷走しています。
|
6
|
-
詳しい方居られましたら、アドバイス頂けますと有難いです。よろしくお願いします。
|
8
|
+
詳しい方居られましたら、アドバイス頂けますと大変有難いです。よろしくお願いします。
|
7
9
|
|
8
10
|
### 発生している問題・エラーメッセージ
|
9
11
|
|
10
12
|
```
|
11
13
|
エラーメッセージは、無いのですが
|
12
|
-
ローカルで、パスワード再設定フォームからアドレスを入れるとサーバーに再設定フォーム用アドレスが生成され
|
14
|
+
ローカルで、パスワード再設定フォームからアドレスを入れるとサーバーに再設定フォーム用アドレスが生成されるはずが、
|
13
|
-
root_urlになってしま
|
15
|
+
root_urlになってしまい、再設定フォームに繋がりません。
|
14
16
|
```
|
15
17
|
|
16
18
|
### 該当のソースコード
|
17
19
|
|
18
20
|
```ここに言語名を入力
|
19
|
-
以下は
|
21
|
+
以下はソースではなくプレビュー画面のテキストです。
|
20
22
|
|
23
|
+
From:
|
24
|
+
noreply@example.com
|
25
|
+
To:
|
26
|
+
eaxmple@railstutorial.org
|
27
|
+
Date:
|
28
|
+
Wed, 05 Feb 2020 13:00:15 +0000
|
29
|
+
Subject:
|
30
|
+
Password reset
|
21
31
|
|
22
|
-
before_action :get_user, only: [:edit, :update]
|
23
|
-
before_action :valid_user, only: [:edit, :update]
|
24
|
-
before_action :check_expiration, only: [:edit, :update]
|
25
32
|
|
26
|
-
|
33
|
+
Password reset
|
27
|
-
|
34
|
+
To reset your password click the link below:
|
28
35
|
|
29
|
-
def create
|
30
|
-
@user = User.find_by(email: params[:password_reset][:email].downcase)
|
31
|
-
if @user
|
32
|
-
@user.create_reset_digest
|
33
|
-
@user.send_password_reset_email
|
34
|
-
flash[:info] = "Email sent with password reset instructions"
|
35
|
-
|
36
|
+
Reset password
|
36
|
-
else
|
37
|
-
|
37
|
+
This link will expire in two hours.
|
38
|
-
render 'new'
|
39
|
-
end
|
40
|
-
end
|
41
38
|
|
42
|
-
|
39
|
+
If you did not request your password to be reset, please ignore this email and your password will stay as it is.
|
43
|
-
end
|
44
40
|
|
45
|
-
def update
|
46
|
-
if params[:user][:password].empty? # (3) への対応
|
47
|
-
@user.errors.add(:password, :blank)
|
48
|
-
render 'edit'
|
49
|
-
elsif @user.update_attributes(user_params) # (4) への対応
|
50
|
-
log_in @user
|
51
|
-
@user.update_attribute(:reset_digest, nil)
|
52
|
-
flash[:success] = "Password has been reset."
|
53
|
-
redirect_to @user
|
54
|
-
else
|
55
|
-
render 'edit' # (2) への対応
|
56
|
-
end
|
57
|
-
end
|
58
41
|
|
59
|
-
private
|
60
|
-
|
61
|
-
def user_params
|
62
|
-
params.require(:user).permit(:password, :password_confirmation)
|
63
|
-
end
|
64
|
-
|
65
|
-
#beforeフィルタ
|
66
|
-
|
67
|
-
def get_user
|
68
|
-
@user = User.find_by(email: params[:email])
|
69
|
-
end
|
70
|
-
|
71
|
-
#正しいユーザーかどうか確認する
|
72
|
-
def valid_user
|
73
|
-
unless (@user && @user.activated? &&
|
74
|
-
@user.authenticated?(:reset, params[:id]))
|
75
|
-
redirect_to root_url
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
#トークンが期限切れかどうか確認する
|
80
|
-
def check_expiration
|
81
|
-
if @user.password_reset_expired?
|
82
|
-
flash[:danger] = "Password reset has expired."
|
83
|
-
redirect_to new_password_reset_url
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
42
|
```
|
91
43
|
|
92
44
|
### 試したこと
|
2
追加です
title
CHANGED
File without changes
|
body
CHANGED
@@ -107,7 +107,7 @@
|
|
107
107
|
Sent mail to ***.***@gmail.com (2.0ms)
|
108
108
|
Date: Mon, 03 Feb 2020 23:17:51 +0900
|
109
109
|
From: noreply@example.com
|
110
|
-
To:
|
110
|
+
To: ***.***@gmail.com
|
111
111
|
Message-ID: <5e382b8f62a73_2fb830046fc3623@DESKTOP-NGDL1L7.mail>
|
112
112
|
Subject: Password reset
|
113
113
|
Mime-Version: 1.0
|
1
サーバーログを載せてみました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -72,7 +72,7 @@
|
|
72
72
|
def valid_user
|
73
73
|
unless (@user && @user.activated? &&
|
74
74
|
@user.authenticated?(:reset, params[:id]))
|
75
|
-
redirect_to root_url
|
75
|
+
redirect_to root_url
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -91,8 +91,114 @@
|
|
91
91
|
|
92
92
|
### 試したこと
|
93
93
|
|
94
|
+
Forgot passwordメールを送って出てきたサーバーログが以下なのですが、Homeのアドレスに必ずなっていて、Reset passwordの
|
94
|
-
|
95
|
+
フォームに繋がりません。いろいろ探したコードチェックもしたのですが、何も落ち度がないのですが、なぜこんな現象が起こるのでしょうか・・。
|
95
96
|
|
97
|
+
Started POST "/password_resets" for 127.0.0.1 at 2020-02-03 23:17:51 +0900
|
98
|
+
Processing by PasswordResetsController#create as HTML
|
99
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"yD6fC+Ioj+4xoHm3hRKD7YcIyMvCvqgz0WtGPzd76Anx19rsWE6TFbOp1SdzIPN325rLS+dH/1xmiDbi19Ce2A==", "password_reset"=>"[FILTERED]", "commit"=>"Submit"}
|
100
|
+
User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "***.***@gmail.com"], ["LIMIT", 1]]
|
101
|
+
SQL (16.0ms) UPDATE "users" SET "reset_digest" = '$2a$10$mP0rEY3TVbBo90YHyoms5eKR3DrmsSVCd4AwPEKpCfY6YgTWYkgty', "reset_sent_at" = '2020-02-03 14:17:51.087040' WHERE "users"."id" = ? [["id", 102]]
|
102
|
+
Rendering user_mailer/password_reset.html.erb within layouts/mailer
|
103
|
+
Rendered user_mailer/password_reset.html.erb within layouts/mailer (1.0ms)
|
104
|
+
Rendering user_mailer/password_reset.text.erb within layouts/mailer
|
105
|
+
Rendered user_mailer/password_reset.text.erb within layouts/mailer (0.0ms)
|
106
|
+
UserMailer#password_reset: processed outbound mail in 288.0ms
|
107
|
+
Sent mail to ***.***@gmail.com (2.0ms)
|
108
|
+
Date: Mon, 03 Feb 2020 23:17:51 +0900
|
109
|
+
From: noreply@example.com
|
110
|
+
To: satoshi.taenaka@gmail.com
|
111
|
+
Message-ID: <5e382b8f62a73_2fb830046fc3623@DESKTOP-NGDL1L7.mail>
|
112
|
+
Subject: Password reset
|
113
|
+
Mime-Version: 1.0
|
114
|
+
Content-Type: multipart/alternative;
|
115
|
+
boundary="--==_mimepart_5e382b8f62294_2fb830046fc3528";
|
116
|
+
charset=UTF-8
|
117
|
+
Content-Transfer-Encoding: 7bit
|
118
|
+
|
119
|
+
|
120
|
+
----==_mimepart_5e382b8f62294_2fb830046fc3528
|
121
|
+
Content-Type: text/plain;
|
122
|
+
charset=UTF-8
|
123
|
+
Content-Transfer-Encoding: 7bit
|
124
|
+
|
125
|
+
To reset your password click the link below:
|
126
|
+
|
127
|
+
http://localhost:3000/password_resets/-6kcTNIBrZspHPPJn5Aoxw/edit?email=***.***%40gmail.com
|
128
|
+
|
129
|
+
This link will expire in two hours.
|
130
|
+
|
131
|
+
If you did not request your password to be reset, please ignore this email and
|
132
|
+
your password will stay as it is.
|
133
|
+
|
134
|
+
|
135
|
+
----==_mimepart_5e382b8f62294_2fb830046fc3528
|
136
|
+
Content-Type: text/html;
|
137
|
+
charset=UTF-8
|
138
|
+
Content-Transfer-Encoding: 7bit
|
139
|
+
|
140
|
+
<!DOCTYPE html>
|
141
|
+
<html>
|
142
|
+
<head>
|
143
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
144
|
+
<style>
|
145
|
+
/* Email styles need to be inline */
|
146
|
+
</style>
|
147
|
+
</head>
|
148
|
+
|
149
|
+
<body>
|
150
|
+
<h1>Password reset</h1>
|
151
|
+
|
152
|
+
<p>To reset your password click the link below:</p>
|
153
|
+
|
154
|
+
<a href="http://localhost:3000/password_resets/-6kcTNIBrZspHPPJn5Aoxw/edit?email=***.***%40gmail.com">Reset password</a>
|
155
|
+
|
156
|
+
<p>This link will expire in two hours.</p>
|
157
|
+
|
158
|
+
<p>
|
159
|
+
If you did not request your password to be reset, please ignore this email and
|
160
|
+
your password will stay as it is.
|
161
|
+
</p>
|
162
|
+
|
163
|
+
</body>
|
164
|
+
</html>
|
165
|
+
|
166
|
+
----==_mimepart_5e382b8f62294_2fb830046fc3528--
|
167
|
+
|
168
|
+
Redirected to http://localhost:3000/
|
169
|
+
Completed 302 Found in 376ms (ActiveRecord: 16.0ms)
|
170
|
+
|
171
|
+
|
172
|
+
Started GET "/" for 127.0.0.1 at 2020-02-03 23:17:51 +0900
|
173
|
+
Processing by StaticPagesController#home as HTML
|
174
|
+
Rendering static_pages/home.html.erb within layouts/application
|
175
|
+
Rendered static_pages/home.html.erb within layouts/application (3.0ms)
|
176
|
+
Rendered layouts/_head.html.erb (111.0ms)
|
177
|
+
Rendered layouts/_shim.html.erb (1.0ms)
|
178
|
+
Rendered layouts/_header.html.erb (1.0ms)
|
179
|
+
Rendered layouts/_footer.html.erb (0.0ms)
|
180
|
+
Completed 200 OK in 292ms (Views: 272.0ms | ActiveRecord: 0.0ms)
|
181
|
+
|
182
|
+
|
183
|
+
Started GET "/password_resets/-6kcTNIBrZspHPPJn5Aoxw/edit?email=satoshi.taenaka%40gmail.com" for 127.0.0.1 at 2020-02-03 23:18:18 +0900
|
184
|
+
Processing by PasswordResetsController#edit as HTML
|
185
|
+
Parameters: {"email"=>"***.***@gmail.com", "id"=>"-6kcTNIBrZspHPPJn5Aoxw"}
|
186
|
+
User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? LIMIT ? [["email", "***.***@gmail.com"], ["LIMIT", 1]]
|
187
|
+
Redirected to http://localhost:3000/
|
188
|
+
Filter chain halted as :valid_user rendered or redirected
|
189
|
+
Completed 302 Found in 4ms (ActiveRecord: 0.0ms)
|
190
|
+
|
191
|
+
|
192
|
+
Started GET "/" for 127.0.0.1 at 2020-02-03 23:18:18 +0900
|
193
|
+
Processing by StaticPagesController#home as HTML
|
194
|
+
Rendering static_pages/home.html.erb within layouts/application
|
195
|
+
Rendered static_pages/home.html.erb within layouts/application (4.0ms)
|
196
|
+
Rendered layouts/_head.html.erb (118.0ms)
|
197
|
+
Rendered layouts/_shim.html.erb (0.0ms)
|
198
|
+
Rendered layouts/_header.html.erb (1.0ms)
|
199
|
+
Rendered layouts/_footer.html.erb (1.0ms)
|
200
|
+
Completed 200 OK in 292ms (Views: 271.0ms | ActiveRecord: 0.0ms)
|
201
|
+
|
96
202
|
### 補足情報(FW/ツールのバージョンなど)
|
97
203
|
|
98
204
|
Windows10 git heroku
|