Skip to content

Commit d1e90d2

Browse files
authored
Merge pull request #1 from jules2689/master
Fix authenticating user inside of an engine
2 parents c68d9ea + 4f6491a commit d1e90d2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/two_factor_authentication/controllers/helpers.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ def handle_failed_second_factor(scope)
3535

3636
def two_factor_authentication_path_for(resource_or_scope = nil)
3737
scope = Devise::Mapping.find_scope!(resource_or_scope)
38+
namespace = if Devise.available_router_name
39+
send(Devise.available_router_name)
40+
else
41+
self
42+
end
3843
change_path = "#{scope}_two_factor_authentication_path"
39-
send(change_path)
44+
namespace.send(change_path)
4045
end
4146

4247
end

lib/two_factor_authentication/models/two_factor_authenticatable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def generate_totp_secret
101101
def create_direct_otp(options = {})
102102
# Create a new random OTP and store it in the database
103103
digits = options[:length] || self.class.direct_otp_length || 6
104-
update_attributes(
104+
update_columns(
105105
direct_otp: random_base10(digits),
106106
direct_otp_sent_at: Time.now.utc
107107
)
@@ -122,7 +122,7 @@ def direct_otp_expired?
122122
end
123123

124124
def clear_direct_otp
125-
update_attributes(direct_otp: nil, direct_otp_sent_at: nil)
125+
update_columns(direct_otp: nil, direct_otp_sent_at: nil)
126126
end
127127
end
128128

0 commit comments

Comments
 (0)