You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: controller_security_question.rb
    path of file: ./repos/devise-security/lib/devise-security/patches
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module DeviseSecurity::Patches
  module ControllerSecurityQuestion
    extend ActiveSupport::Concern

    included do
      prepend_before_action :check_sec
    
    def check_security_question
      # only find via email, not login
      resource = resource_class.find_or_initialize_with_error_by(:email, params[resource_name][:email], :not_found)
      return if valid_security_question_answer?(resource, params[:security_question_answer])

      flash[:alert] = t('devise.invalid_security_question') if is_navigational_format?
      respond_with({}, location: url_for(action: :new))
    end