質問編集履歴
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,145 +1,84 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
|
-
|
3
2
|
ttps://www.autovice.jp/articles/171#part-f25eff337beca913
|
4
|
-
|
5
3
|
こちらのサイトを参考にrotpを使った2段階認証の実装を勉強しているのですが、
|
6
4
|
|
7
|
-
|
8
|
-
|
9
5
|
NameError in TwoStepVerifications#new
|
10
|
-
|
11
6
|
Showing C:/Users/user/rails/login_app/app/views/two_step_verifications/new.html.erb
|
12
|
-
|
13
7
|
Did you mean? @otp_secret
|
14
|
-
|
15
|
-
|
16
8
|
|
17
9
|
が出て、QRコードの画面がでません。該当する箇所を変更(otp_secret_path → @otp_secret)したのち、QRコードは表示できるようになったのですが、認証しようとすると
|
18
10
|
|
19
|
-
|
20
|
-
|
21
11
|
No route matches [POST] "/two_step_verifications/ランダムな文字列"
|
22
|
-
|
23
|
-
|
24
12
|
|
25
13
|
と出て上手く認証できません。
|
26
14
|
|
27
|
-
|
28
|
-
|
29
15
|
当方、まったくの初心者で稚拙なところも多々あると思いますが、よろしければお力添えをお願いします。
|
30
|
-
|
31
|
-
|
32
16
|
|
33
17
|
### 発生している問題・エラーメッセージ
|
34
18
|
|
19
|
+
```
|
20
|
+
NameError in TwoStepVerification#new
|
21
|
+
Showing C:/Users/user/rails/login_app/app/views/two_step_verification/new.html.erb where line #3 raised:
|
22
|
+
|
23
|
+
undefined local variable or method `otp_secrets_path' for #<ActionView::Base:0x00000000006c60>
|
24
|
+
Did you mean? @otp_secret
|
25
|
+
```
|
26
|
+
```
|
27
|
+
No route matches [POST] "/two_step_verification/EM7ADJLIUK2SZ3PL6Q4NQ2KYKM3M6C4J"
|
28
|
+
Rails.root: C:/Users/user/rails/login_app
|
29
|
+
|
30
|
+
Application Trace | Framework Trace | Full Trace
|
31
|
+
Routes
|
32
|
+
Routes match in priority from top to bottom
|
35
33
|
|
36
34
|
|
37
35
|
```
|
38
36
|
|
37
|
+
### 該当のソースコード
|
38
|
+
|
39
|
+
```rails
|
40
|
+
|
41
|
+
#login_app\app\views\two_step_verifications\new.html.erb
|
42
|
+
|
43
|
+
<h2>2-Step Verification</h2>
|
44
|
+
|
45
|
+
#以下赤文字
|
46
|
+
<%= form_tag otp_secret_path, method: :post do %>
|
47
|
+
<%= hidden_field_tag :otp_secret, @otp_secret %>
|
48
|
+
|
49
|
+
<div class='field'>
|
50
|
+
<%= image_tag @qr_code %>
|
51
|
+
</div>
|
52
|
+
|
53
|
+
<div class='field'>
|
54
|
+
<%= label_tag :otp_attempt, 'Verify' %> <i>(enter a one-time password)</i><br />
|
55
|
+
<%= text_field_tag :otp_attempt %>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<div class='actions'>
|
59
|
+
<%= submit_tag 'Verify' %>
|
60
|
+
</div>
|
61
|
+
<% end %>
|
62
|
+
```
|
63
|
+
|
64
|
+
### 該当のソースコード
|
65
|
+
|
66
|
+
```rails
|
67
|
+
#login_app\config\routes.rb
|
68
|
+
|
69
|
+
Rails.application.routes.draw do
|
70
|
+
resources :two_step_verification, only: [:new, :create]
|
71
|
+
|
39
|
-
|
72
|
+
get 'two_step_verifications/new'
|
73
|
+
get 'two_step_verifications/create'
|
74
|
+
devise_for :users
|
75
|
+
root to:'comments#index'
|
76
|
+
get 'comments/index'
|
77
|
+
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
|
78
|
+
end
|
40
79
|
|
41
80
|
```
|
42
81
|
|
43
|
-
```
|
44
|
-
|
45
|
-
No route matches [POST] "/two_step_verifications/ランダムな文字列"
|
46
|
-
|
47
|
-
```
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
### 該当のソースコード
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
```rails
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
#login_app\app\views\two_step_verifications\new.html.erb
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
<h2>2-Step Verification</h2>
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
#以下赤文字
|
68
|
-
|
69
|
-
<%= form_tag otp_secret_path, method: :post do %>
|
70
|
-
|
71
|
-
<%= hidden_field_tag :otp_secret, @otp_secret %>
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
<div class='field'>
|
76
|
-
|
77
|
-
<%= image_tag @qr_code %>
|
78
|
-
|
79
|
-
</div>
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
<div class='field'>
|
84
|
-
|
85
|
-
<%= label_tag :otp_attempt, 'Verify' %> <i>(enter a one-time password)</i><br />
|
86
|
-
|
87
|
-
<%= text_field_tag :otp_attempt %>
|
88
|
-
|
89
|
-
</div>
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
<div class='actions'>
|
94
|
-
|
95
|
-
<%= submit_tag 'Verify' %>
|
96
|
-
|
97
|
-
</div>
|
98
|
-
|
99
|
-
<% end %>
|
100
|
-
|
101
|
-
```
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
### 該当のソースコード
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
```rails
|
110
|
-
|
111
|
-
#login_app\config\routes.rb
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
Rails.application.routes.draw do
|
116
|
-
|
117
|
-
resources :two_step_verification, only: [:new, :create]
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
get 'two_step_verifications/new'
|
122
|
-
|
123
|
-
get 'two_step_verifications/create'
|
124
|
-
|
125
|
-
devise_for :users
|
126
|
-
|
127
|
-
root to:'comments#index'
|
128
|
-
|
129
|
-
get 'comments/index'
|
130
|
-
|
131
|
-
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
```
|
138
|
-
|
139
|
-
|
140
|
-
|
141
82
|
### 試したこと
|
142
83
|
|
143
|
-
|
144
|
-
|
145
84
|
該当する箇所を変更(otp_secret_path → @otp_secret)
|