質問編集履歴
4
rails routesの結果追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -239,3 +239,89 @@
|
|
239
239
|
end
|
240
240
|
|
241
241
|
```
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
```ruby
|
246
|
+
|
247
|
+
rails routes
|
248
|
+
|
249
|
+
Prefix Verb URI Pattern Controller#Action
|
250
|
+
|
251
|
+
letter_opener_web /letter_opener LetterOpenerWeb::Engine
|
252
|
+
|
253
|
+
root GET /
|
254
|
+
|
255
|
+
new_user_confirmation GET /users/confirmation/new(.:format) users/confirmations#new {:subdomain=>""}
|
256
|
+
|
257
|
+
user_confirmation GET /users/confirmation(.:format) users/confirmations#show {:subdomain=>""}
|
258
|
+
|
259
|
+
POST /users/confirmation(.:format) users/confirmations#create {:subdomain=>""}
|
260
|
+
|
261
|
+
users_sign_up GET /users/sign_up(.:format) users/registrations#new {:subdomain=>""}
|
262
|
+
|
263
|
+
user_registration POST /user_create(.:format) users/registrations#create {:subdomain=>""}
|
264
|
+
|
265
|
+
user_update_registration PUT /user_create(.:format) users/registrations#update {:subdomain=>""}
|
266
|
+
|
267
|
+
user_destroy_registration DELETE /user_create(.:format) users/registrations#destroy {:subdomain=>""}
|
268
|
+
|
269
|
+
company_top GET / companies#top {:subdomain=>"company"}
|
270
|
+
|
271
|
+
new_company_session GET /companies/sign_in(.:format) companies/sessions#new {:subdomain=>"company"}
|
272
|
+
|
273
|
+
company_session POST /companies/sign_in(.:format) companies/sessions#create {:subdomain=>"company"}
|
274
|
+
|
275
|
+
destroy_company_session DELETE /companies/sign_out(.:format) companies/sessions#destroy {:subdomain=>"company"}
|
276
|
+
|
277
|
+
new_company_confirmation GET /companies/confirmation/new(.:format) companies/confirmations#new {:subdomain=>"company"}
|
278
|
+
|
279
|
+
company_confirmation GET /companies/confirmation(.:format) companies/confirmations#show {:subdomain=>"company"}
|
280
|
+
|
281
|
+
POST /companies/confirmation(.:format) companies/confirmations#create {:subdomain=>"company"}
|
282
|
+
|
283
|
+
accept_company_invitation GET /companies/invitation/accept(.:format) companies/invitations#edit {:subdomain=>"company"}
|
284
|
+
|
285
|
+
remove_company_invitation GET /companies/invitation/remove(.:format) companies/invitations#destroy {:subdomain=>"company"}
|
286
|
+
|
287
|
+
new_company_invitation GET /companies/invitation/new(.:format) companies/invitations#new {:subdomain=>"company"}
|
288
|
+
|
289
|
+
company_invitation PATCH /companies/invitation(.:format) companies/invitations#update {:subdomain=>"company"}
|
290
|
+
|
291
|
+
PUT /companies/invitation(.:format) companies/invitations#update {:subdomain=>"company"}
|
292
|
+
|
293
|
+
POST /companies/invitation(.:format) companies/invitations#create {:subdomain=>"company"}
|
294
|
+
|
295
|
+
company_registration_new GET /companies/sign_up(.:format) companies/registrations#new {:subdomain=>"company"}
|
296
|
+
|
297
|
+
company_registration_complete GET /companies/confirm(.:format) companies/registrations#confirm {:subdomain=>"company"}
|
298
|
+
|
299
|
+
company_registration_done GET /companies/done(.:format) companies/registrations#done {:subdomain=>"company"}
|
300
|
+
|
301
|
+
company_registration_create POST /company_create(.:format) companies/registrations#create {:subdomain=>"company"}
|
302
|
+
|
303
|
+
company_password_done GET /password/done(.:format) companies/passwords#done {:subdomain=>"company"}
|
304
|
+
|
305
|
+
confirm_company_invitation POST /invitation/confirm(.:format) companies/invitations#confirm {:subdomain=>"company"}
|
306
|
+
|
307
|
+
invitation_done GET /invitation/done(.:format) companies/invitations#done {:subdomain=>"company"
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
Routes for LetterOpenerWeb::Engine:
|
314
|
+
|
315
|
+
clear_letters DELETE /clear(.:format) letter_opener_web/letters#clear
|
316
|
+
|
317
|
+
delete_letter DELETE /:id(.:format) letter_opener_web/letters#destroy
|
318
|
+
|
319
|
+
letters GET / letter_opener_web/letters#index
|
320
|
+
|
321
|
+
letter GET /:id(/:style)(.:format) letter_opener_web/letters#show
|
322
|
+
|
323
|
+
GET /:id/attachments/:file(.:format) letter_opener_web/letters#attachment
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
```
|
3
再現URLの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,6 +56,18 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
+
追記ーーーーーーーーーーーー
|
60
|
+
|
61
|
+
OKなURL:
|
62
|
+
|
63
|
+
https://localhost:3001/users/confirmation?confirmation_token=jJKBCgMK9sdMb-tgEkco
|
64
|
+
|
65
|
+
NGなURL:
|
66
|
+
|
67
|
+
~~https~~://company.localhost:3001/companies/confirmation?confirmation_token=iFe9BQvWXztHWegPn33v
|
68
|
+
|
69
|
+
追記ーーーーーーーーーーーー
|
70
|
+
|
59
71
|
|
60
72
|
|
61
73
|
![![イメージ説明](97cdfcc91871a87018c6a8ecbdb85afa.png)](5ecaae57305faed68e2710dd01c55f2f.png)
|
2
認証URLの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,6 +24,12 @@
|
|
24
24
|
|
25
25
|
上記操作をすると、認証URLから飛んだらrouting errorがおきます。
|
26
26
|
|
27
|
+
url:
|
28
|
+
|
29
|
+
https://company.localhost:3001/companies/confirmation?confirmation_token=QhUcNyibR7sJrVRs61-F
|
30
|
+
|
31
|
+
|
32
|
+
|
27
33
|
しかし、routesを確認すると存在しています。
|
28
34
|
|
29
35
|
サブドメインでないroutesのユーザーは、deviseのメール内の認証URLから認証できました。
|
1
ソースファイルの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -109,3 +109,115 @@
|
|
109
109
|
end
|
110
110
|
|
111
111
|
```
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
|
115
|
+
app/views/companies/mailer/confirmation_instructins.html.erb
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<p>Welcome <%= @email %>!</p>
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<p>You can confirm your account email through the link below:</p>
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
<p><%= link_to 'アカウントを有効にする', controller: 'companies/confirmations', action: 'create', confirmation_token: @token %></p>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
```
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
|
135
|
+
app/controllers/mailer.rb
|
136
|
+
|
137
|
+
class Mailer < Devise::Mailer
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
# User
|
142
|
+
|
143
|
+
def confirmation_instructions(record, token, opts={})
|
144
|
+
|
145
|
+
mail = super
|
146
|
+
|
147
|
+
if record.class == Company
|
148
|
+
|
149
|
+
mail.subject = "会社メールアドレス認証のお願い"
|
150
|
+
|
151
|
+
elsif ecord.class == Admin
|
152
|
+
|
153
|
+
mail.subject = "管理者アカウントのメールアドレス認証のお願い"
|
154
|
+
|
155
|
+
else # User
|
156
|
+
|
157
|
+
mail.subject = "アカウントのメールアドレス認証のお願い"
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
mail
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
```
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
|
171
|
+
app/controllers/companies/confirmations_controller.rb
|
172
|
+
|
173
|
+
# frozen_string_literal: true
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
class Companies::ConfirmationsController < Devise::ConfirmationsController
|
178
|
+
|
179
|
+
# GET /resource/confirmation/new
|
180
|
+
|
181
|
+
# def new
|
182
|
+
|
183
|
+
# super
|
184
|
+
|
185
|
+
# end
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
# POST /resource/confirmation
|
190
|
+
|
191
|
+
# def create
|
192
|
+
|
193
|
+
# super
|
194
|
+
|
195
|
+
# end
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
# GET /resource/confirmation?confirmation_token=abcdef
|
200
|
+
|
201
|
+
# def show
|
202
|
+
|
203
|
+
# super
|
204
|
+
|
205
|
+
# end
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
# protected
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
# The path used after resending confirmation instructions.
|
214
|
+
|
215
|
+
def after_resending_confirmation_instructions_path_for(resource_name)
|
216
|
+
|
217
|
+
company_top_path
|
218
|
+
|
219
|
+
# super(resource_name)
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
```
|