Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
fix email otp bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
reesericci committed Nov 20, 2023
1 parent 9abf928 commit 189b88f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/auth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def email
end


if !(Time.now.to_i <= user.otp_last_minted + 600) || params[:resend] == "true" then
if Time.now.to_i > (user.otp_last_minted.nil? ? 0 : user.otp_last_minted) + 600 || params[:resend] == "true" then
User::Mailer.with(user: user).verification_email.deliver_later
end

Expand Down
3 changes: 2 additions & 1 deletion app/models/user/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class User::User < ApplicationRecord
end

def mint_otp
self.otp_counter += 1
otp = @hotp.at(self.otp_counter)
self.otp_last_minted = Time.now.to_i
self.save
Expand All @@ -29,4 +30,4 @@ def use_otp(token)
end
end

end
end

0 comments on commit 189b88f

Please sign in to comment.