Skip to content

Commit

Permalink
Merge pull request #1 from jules2689/master
Browse files Browse the repository at this point in the history
Fix authenticating user inside of an engine
  • Loading branch information
willtcarey authored Jan 13, 2023
2 parents c68d9ea + 4f6491a commit d1e90d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/two_factor_authentication/controllers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ def handle_failed_second_factor(scope)

def two_factor_authentication_path_for(resource_or_scope = nil)
scope = Devise::Mapping.find_scope!(resource_or_scope)
namespace = if Devise.available_router_name
send(Devise.available_router_name)
else
self
end
change_path = "#{scope}_two_factor_authentication_path"
send(change_path)
namespace.send(change_path)
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def generate_totp_secret
def create_direct_otp(options = {})
# Create a new random OTP and store it in the database
digits = options[:length] || self.class.direct_otp_length || 6
update_attributes(
update_columns(
direct_otp: random_base10(digits),
direct_otp_sent_at: Time.now.utc
)
Expand All @@ -122,7 +122,7 @@ def direct_otp_expired?
end

def clear_direct_otp
update_attributes(direct_otp: nil, direct_otp_sent_at: nil)
update_columns(direct_otp: nil, direct_otp_sent_at: nil)
end
end

Expand Down

0 comments on commit d1e90d2

Please sign in to comment.