challenges_controller.rb 545 B

12345678910111213141516171819202122
  1. # frozen_string_literal: true
  2. class Auth::ChallengesController < ApplicationController
  3. include ChallengableConcern
  4. layout 'auth'
  5. before_action :authenticate_user!
  6. skip_before_action :require_functional!
  7. def create
  8. if challenge_passed?
  9. session[:challenge_passed_at] = Time.now.utc
  10. redirect_to challenge_params[:return_to]
  11. else
  12. @challenge = Form::Challenge.new(return_to: challenge_params[:return_to])
  13. flash.now[:alert] = I18n.t('challenge.invalid_password')
  14. render_challenge
  15. end
  16. end
  17. end