File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ def otp_regenerate_counter
7272 end
7373
7474 def authenticate_otp ( code , options = { } )
75+ return false if code . nil? || code . empty?
7576 return true if backup_codes_enabled? && authenticate_backup_code ( code )
7677
7778 if otp_counter_based
Original file line number Diff line number Diff line change @@ -33,6 +33,23 @@ def test_authenticate_with_otp
3333 assert @visitor . authenticate_otp ( code )
3434 end
3535
36+ def test_authenticate_with_otp_passing_false_or_empty_codes
37+ refute @user . authenticate_otp ( nil )
38+ refute @user . authenticate_otp ( '' )
39+
40+ refute @visitor . authenticate_otp ( nil )
41+ refute @visitor . authenticate_otp ( '' )
42+
43+ refute @member . authenticate_otp ( nil )
44+ refute @member . authenticate_otp ( '' )
45+
46+ refute @ar_user . authenticate_otp ( nil )
47+ refute @ar_user . authenticate_otp ( '' )
48+
49+ refute @opt_in . authenticate_otp ( nil )
50+ refute @opt_in . authenticate_otp ( '' )
51+ end
52+
3653 def test_counter_based_otp
3754 code = @member . otp_code
3855 assert @member . authenticate_otp ( code )
You can’t perform that action at this time.
0 commit comments