Module: Kiqr::Controllers::TwoFactorAuthentication
- Extended by:
- ActiveSupport::Concern
- Included in:
- OmniauthCallbacksController, SessionsController
- Defined in:
- lib/kiqr/controllers/two_factor_authentication.rb
Instance Method Summary collapse
-
#authenticate_with_two_factor ⇒ Object
This method is called before authenticating a user and will prompt the user for their two-factor authentication code if they have it enabled.
Instance Method Details
#authenticate_with_two_factor ⇒ Object
This method is called before authenticating a user and will prompt the user for their two-factor authentication code if they have it enabled. Used in users/sessions_controller.rb and users/omniauth_controller.rb
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/kiqr/controllers/two_factor_authentication.rb', line 9 def authenticate_with_two_factor # Allow :otp_attempt to be permitted as a parameter for sign_in devise_parameter_sanitizer.permit(:sign_in, keys: [ :otp_attempt ]) user = find_user if sign_in_params[:otp_attempt].present? && session[:otp_user_id] authenticate_via_otp(user) elsif user && user.valid_password?(sign_in_params[:password]) prompt_for_two_factor(user) end end |