質問編集履歴
5
説明を変更しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
現在簡単なECサイトを作成しています。
|
2
2
|
|
3
|
-
|
3
|
+
メール送信によるパスワードリセットで新しいパスワードを入力したところ
|
4
4
|
|
5
5
|
|
6
6
|
|
4
変更しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -41,8 +41,6 @@
|
|
41
41
|
Ruby on Rails: 4.2.5
|
42
42
|
|
43
43
|
devise(gem):4.5.0
|
44
|
-
|
45
|
-
デプロイ先:AWS
|
46
44
|
|
47
45
|
確認ブラウザ:chrome、firefox
|
48
46
|
|
3
ルーティングを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,6 +28,12 @@
|
|
28
28
|
|
29
29
|
パスワードリセットができるようになってほしい
|
30
30
|
|
31
|
+
|
32
|
+
|
33
|
+
### 疑問
|
34
|
+
|
35
|
+
- パスワード忘れによるリセットをしたいが下記のルーティングのedit_user_password_urlであっているのか?
|
36
|
+
|
31
37
|
###動作環境
|
32
38
|
|
33
39
|
Ruby:2.3.5
|
@@ -46,9 +52,45 @@
|
|
46
52
|
|
47
53
|
###試したこと
|
48
54
|
|
49
|
-
|
55
|
+
[devise 新規登録時にパスワードリセットメールを送信したいのでやってみた](https://qiita.com/motty93/items/2862f1cb6daabe6e4c55)
|
50
56
|
|
57
|
+
rake routesコマンドで
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
new_user_session GET /users/sign_in(.:format) users/sessions#new
|
62
|
+
|
63
|
+
user_session POST /users/sign_in(.:format) users/sessions#create
|
64
|
+
|
65
|
+
destroy_user_session GET /users/sign_out(.:format) users/sessions#destroy
|
66
|
+
|
67
|
+
user_facebook_omniauth_authorize GET|POST /users/auth/facebook(.:format)
|
68
|
+
|
69
|
+
/users/omniauth_callbacks#passthru
|
70
|
+
|
71
|
+
user_facebook_omniauth_callback GET|POST /users/auth/facebook/callback(.:format) users/omniauth_callbacks#facebook
|
72
|
+
|
73
|
+
user_google_omniauth_authorize GET|POST /users/auth/google(.:format) users/omniauth_callbacks#passthru
|
74
|
+
|
75
|
+
user_google_omniauth_callback GET|POST /users/auth/google/callback(.:format) users/omniauth_callbacks#google
|
76
|
+
|
77
|
+
user_password POST /users/password(.:format) users/passwords#create
|
78
|
+
|
79
|
+
new_user_password GET /users/password/new(.:format) users/passwords#new
|
80
|
+
|
51
|
-
|
81
|
+
edit_user_password GET /users/password/edit(.:format) users/passwords#edit
|
82
|
+
|
83
|
+
PATCH /users/password(.:format) users/passwords#update
|
84
|
+
|
85
|
+
PUT /users/password(.:format) users/passwords#update
|
86
|
+
|
87
|
+
cancel_user_registration GET /users/cancel(.:format) users/registrations#cancel
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
で確認し、`reset_password_instructions.html.erb`を変更してみましたが変わりませんでした。
|
92
|
+
|
93
|
+
|
52
94
|
|
53
95
|
###関係ありそうなソースコード
|
54
96
|
|
2
修正を加えました
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,19 +14,15 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
ちなみにdeviseで既存のコードを変更した部分はdestroyアクションになります(退会処理を変更するため)
|
18
|
-
|
19
17
|
|
20
18
|
|
21
19
|
###エラー内容
|
22
20
|
|
23
21
|
メール送信によるパスワードリセットがうまくいかない
|
24
22
|
|
23
|
+

|
25
24
|
|
26
25
|
|
27
|
-
※firefoxでの「要素を調査」の該当部分
|
28
|
-
|
29
|
-

|
30
26
|
|
31
27
|
###期待する動作
|
32
28
|
|
@@ -44,33 +40,25 @@
|
|
44
40
|
|
45
41
|
確認ブラウザ:chrome、firefox
|
46
42
|
|
47
|
-
###参考サイト
|
48
|
-
|
49
|
-
[Rails 4 + Devise: Password Reset is always giving a “Token is invalid” error on the production server, but works fine locally.](https://stackoverflow.com/questions/19018657/rails-4-devise-password-reset-is-always-giving-a-token-is-invalid-error-on)
|
50
43
|
|
51
44
|
|
52
45
|
|
53
|
-
[reset_password_token(invitation_token)が上書きされてまう、Mac Sierra Safariで!](https://qiita.com/kshimadutsu/items/ed3ae8dd10f67997cb7d)
|
54
|
-
|
55
|
-
↗︎
|
56
|
-
|
57
|
-
こちらは修正する場所がわからず何もしていません
|
58
46
|
|
59
47
|
###試したこと
|
60
48
|
|
61
|
-
|
49
|
+
下記サイトの内容がそれっぽかったので変更をしてみましたがエラーは変わりませんでした。
|
62
50
|
|
63
|
-
|
51
|
+
[devise 新規登録時にパスワードリセットメールを送信したいのでやってみた](https://qiita.com/motty93/items/2862f1cb6daabe6e4c55)
|
64
52
|
|
65
53
|
###関係ありそうなソースコード
|
66
54
|
|
67
|
-
|
55
|
+
reset_password_instructions.html.erb
|
68
56
|
|
69
57
|
```ruby
|
70
58
|
|
71
59
|
<p>Hello <%= @resource.email %>!</p>
|
72
60
|
|
73
|
-
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
|
61
|
+
<p><%= link_to 'Change my password', edit_user_password_url(@resource, reset_password_token: @token) %></p>
|
74
62
|
|
75
63
|
|
76
64
|
|
@@ -112,126 +100,12 @@
|
|
112
100
|
|
113
101
|
class User < ActiveRecord::Base
|
114
102
|
|
115
|
-
# Include default devise modules. Others available are:
|
116
|
-
|
117
|
-
# :confirmable, :lockable, :timeoutable and :omniauthable
|
118
|
-
|
119
103
|
devise :database_authenticatable, :registerable,
|
120
104
|
|
121
105
|
:recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable
|
122
106
|
|
107
|
+
.
|
123
108
|
|
124
|
-
|
125
|
-
# logical-delete user
|
126
|
-
|
127
|
-
def logical_delete
|
128
|
-
|
129
|
-
update_attribute(:soft_destroyed_at, Time.current)
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
new_email = Time.current.to_s + '_' + self.email.to_s
|
134
|
-
|
135
|
-
self.skip_reconfirmation!
|
136
|
-
|
137
|
-
self.update_attribute(:email, new_email)
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
unless self.uid.blank?
|
142
|
-
|
143
|
-
uid = self.uid + '_' + Time.current.to_s
|
144
|
-
|
145
|
-
self.update_attribute(:uid, uid)
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
def self.find_for_oauth(auth)
|
156
|
-
|
157
|
-
user = User.where(uid: auth.uid, provider: auth.provider).first
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
unless user
|
162
|
-
|
163
|
-
user = User.create(
|
164
|
-
|
165
|
-
uid: auth.uid,
|
166
|
-
|
167
|
-
provider: auth.provider,
|
168
|
-
|
169
|
-
email: User.dummy_email(auth),
|
170
|
-
|
171
|
-
password: Devise.friendly_token[0, 20]
|
172
|
-
|
173
|
-
|
109
|
+
.
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
user
|
180
|
-
|
181
|
-
end
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
private
|
190
|
-
|
191
|
-
def self.dummy_email(auth)
|
192
|
-
|
193
|
-
"#{auth.uid}-#{auth.provider}@example.com"
|
194
|
-
|
195
|
-
end
|
196
|
-
|
197
|
-
end
|
198
110
|
|
199
111
|
```
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
app/controllers/public/settings/users/registrations_controller.rb
|
206
|
-
|
207
|
-
```ruby
|
208
|
-
|
209
|
-
# frozen_string_literal: true
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
class Public::Settings::Users::RegistrationsController < Devise::RegistrationsController
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
# DELETE /resource
|
218
|
-
|
219
|
-
def destroy
|
220
|
-
|
221
|
-
# super
|
222
|
-
|
223
|
-
resource.logical_delete
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
redirect_to root_path
|
232
|
-
|
233
|
-
end
|
234
|
-
|
235
|
-
end
|
236
|
-
|
237
|
-
```
|
1
参考サイトの記述を少し変更しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,11 +52,13 @@
|
|
52
52
|
|
53
53
|
[reset_password_token(invitation_token)が上書きされてまう、Mac Sierra Safariで!](https://qiita.com/kshimadutsu/items/ed3ae8dd10f67997cb7d)
|
54
54
|
|
55
|
-
|
55
|
+
↗︎
|
56
|
+
|
57
|
+
こちらは修正する場所がわからず何もしていません
|
56
58
|
|
57
59
|
###試したこと
|
58
60
|
|
59
|
-
上記サイトの通り変更をしてみましたが
|
61
|
+
上記サイトの通り変更をしてみましたがエラーは変わりませんでした。
|
60
62
|
|
61
63
|
|
62
64
|
|