File tree Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Original file line number Diff line number Diff line change 16
16
<% if rodauth . logged_in_via_remember_key? %>
17
17
< li > < a href ="/confirm-password "> Confirm Password</ a > </ li >
18
18
<% end %>
19
- <% if rodauth . uses_two_factor_authentication? && !rodauth . two_factor_authenticated? %>
20
- < li > < a href ="/multifactor-auth "> Authenticate Using Additional Factor</ a > </ li >
21
- <% else %>
19
+ <% if rodauth . two_factor_authentication_satisfied? %>
22
20
< li > < a href ="/multifactor-manage "> Manage Multifactor Authentication</ a > </ li >
21
+ <% else %>
22
+ < li > < a href ="/multifactor-auth "> Authenticate Using Additional Factor</ a > </ li >
23
23
<% end %>
24
24
</ ul >
25
25
<% else %>
Original file line number Diff line number Diff line change @@ -124,23 +124,12 @@ def two_factor_modifications_require_password?
124
124
end
125
125
126
126
def authenticated?
127
- # False if not authenticated via single factor
128
- return false unless super
129
-
130
- # True if already authenticated via 2nd factor
131
- return true if two_factor_authenticated?
132
-
133
- # True if authenticated via single factor and 2nd factor not setup
134
- !uses_two_factor_authentication?
127
+ super && two_factor_authentication_satisfied?
135
128
end
136
129
137
130
def require_authentication
138
131
super
139
-
140
- # Avoid database query if already authenticated via 2nd factor
141
- return if two_factor_authenticated?
142
-
143
- require_two_factor_authenticated if uses_two_factor_authentication?
132
+ require_two_factor_authenticated unless two_factor_authentication_satisfied?
144
133
end
145
134
146
135
def require_two_factor_setup
@@ -188,6 +177,10 @@ def two_factor_password_match?(password)
188
177
end
189
178
end
190
179
180
+ def two_factor_authentication_satisfied?
181
+ two_factor_authenticated? || !uses_two_factor_authentication?
182
+ end
183
+
191
184
def two_factor_authenticated?
192
185
authenticated_by && authenticated_by . length >= 2
193
186
end
You can’t perform that action at this time.
0 commit comments