config/initializers/trestle.rb in trestle-auth-otp-0.1.0 vs config/initializers/trestle.rb in trestle-auth-otp-0.1.1
- old
+ new
@@ -2,6 +2,24 @@
config.hook('auth.login.form') do
render 'trestle/auth/otp'
end
+ config.auth.authenticate = ->(params) {
+
+ scope = Trestle.config.auth.user_scope
+
+ user = scope.authenticate(params[Trestle.config.auth.authenticate_with], params[:password])
+
+ if user && user.otp_module?
+ if params[:otp_code_token].present? && user.authenticate_otp(params[:otp_code_token], drift: 60)
+ return user
+ else
+ return false
+ end
+ else
+ return user
+ end
+
+ }
+
end