diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-09-18 16:37:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-18 16:37:27 +0200 |
commit | e1066cd4319a220d5be16e51ffaf5236a2f6e866 (patch) | |
tree | 3cac387721ffb3cefa66d96d1867ae88c9e249ce /app/controllers/auth | |
parent | d0c2c5278391b82ba7fa2f230bf237805ff61a0c (diff) |
Add password challenge to 2FA settings, e-mail notifications (#11878)
Fix #3961
Diffstat (limited to 'app/controllers/auth')
-rw-r--r-- | app/controllers/auth/challenges_controller.rb | 22 | ||||
-rw-r--r-- | app/controllers/auth/sessions_controller.rb | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/app/controllers/auth/challenges_controller.rb b/app/controllers/auth/challenges_controller.rb new file mode 100644 index 000000000..060944240 --- /dev/null +++ b/app/controllers/auth/challenges_controller.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class Auth::ChallengesController < ApplicationController + include ChallengableConcern + + layout 'auth' + + before_action :authenticate_user! + + skip_before_action :require_functional! + + def create + if challenge_passed? + session[:challenge_passed_at] = Time.now.utc + redirect_to challenge_params[:return_to] + else + @challenge = Form::Challenge.new(return_to: challenge_params[:return_to]) + flash.now[:alert] = I18n.t('challenge.invalid_password') + render_challenge + end + end +end diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index 3e93b2e68..b3113bbef 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -42,6 +42,7 @@ class Auth::SessionsController < Devise::SessionsController def destroy tmp_stored_location = stored_location_for(:user) super + session.delete(:challenge_passed_at) flash.delete(:notice) store_location_for(:user, tmp_stored_location) if continue_after? end |