Skip to content

Commit

Permalink
Fix #4026 - Accept backup codes for disabling 2FA (#4382)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Jul 26, 2017
1 parent 55bee84 commit 92cb451
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create
end

def destroy
if current_user.validate_and_consume_otp!(confirmation_params[:code])
if acceptable_code?
current_user.otp_required_for_login = false
current_user.save!
redirect_to settings_two_factor_authentication_path
Expand All @@ -38,5 +38,10 @@ def confirmation_params
def verify_otp_required
redirect_to settings_two_factor_authentication_path if current_user.otp_required_for_login?
end

def acceptable_code?
current_user.validate_and_consume_otp!(confirmation_params[:code]) ||
current_user.invalidate_otp_backup_code!(confirmation_params[:code])
end
end
end

0 comments on commit 92cb451

Please sign in to comment.