feat(mfa): allow disabling 2FA with a backup code when authenticator is lost

This commit is contained in:
Tanmay Deep Sharma
2026-04-20 14:19:10 +07:00
parent 6cbddbdb67
commit 6094060381
5 changed files with 44 additions and 8 deletions
@@ -48,7 +48,8 @@ class Api::V1::Profile::MfaController < Api::BaseController
def validate_otp
authenticated = Mfa::AuthenticationService.new(
user: current_user,
otp_code: mfa_params[:otp_code]
otp_code: mfa_params[:otp_code],
backup_code: mfa_params[:backup_code]
).authenticate
return if authenticated
@@ -63,6 +64,6 @@ class Api::V1::Profile::MfaController < Api::BaseController
end
def mfa_params
params.permit(:otp_code, :password)
params.permit(:otp_code, :backup_code, :password)
end
end