Skip to content

Commit

Permalink
Update one_time_password.rb (#67)
Browse files Browse the repository at this point in the history
When using auto_increment it wouldn't save the model so when I had a different instance of the user the counter would never match.
  • Loading branch information
bartpalmtree authored Jun 16, 2020
1 parent 7ac1fab commit 43684f2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/active_model/one_time_password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def authenticate_otp(code, options = {})
result = hotp.verify(code, otp_counter)
if result && options[:auto_increment]
self.otp_counter += 1
save if respond_to?(:new_record?) && !new_record?
save if respond_to?(:changed?) && !new_record?
end
result
else
Expand All @@ -66,7 +66,7 @@ def otp_code(options = {})
if otp_counter_based
if options[:auto_increment]
self.otp_counter += 1
save if respond_to?(:new_record?) && !new_record?
save if respond_to?(:changed?) && !new_record?
end
ROTP::HOTP.new(otp_column, digits: otp_digits).at(self.otp_counter)
else
Expand Down

0 comments on commit 43684f2

Please sign in to comment.