From 649be2bed9a197c00357763996f375f49855fd66 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Fri, 4 Feb 2022 10:16:04 +0000 Subject: [PATCH] Allow form to be created with model --- .../devise/two_factor_authentication_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/devise/two_factor_authentication_controller.rb b/app/controllers/devise/two_factor_authentication_controller.rb index b3a9dcc..0f16a2e 100644 --- a/app/controllers/devise/two_factor_authentication_controller.rb +++ b/app/controllers/devise/two_factor_authentication_controller.rb @@ -8,9 +8,9 @@ class Devise::TwoFactorAuthenticationController < DeviseController end def update - render :show and return if params[:code].nil? + render :show, status: :unprocessable_entity and return if params_code.empty? - if resource.authenticate_otp(params[:code]) + if resource.authenticate_otp(params_code) after_two_factor_success_for(resource) else after_two_factor_fail_for(resource) @@ -81,4 +81,8 @@ class Devise::TwoFactorAuthenticationController < DeviseController render :max_login_attempts_reached and return end end + + def params_code + params[:code] || params.dig(resource_name, :code) + end end