File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -121,22 +121,29 @@ def setup_2fa():
121121@auth_bp .route ('/disable-2fa' , methods = ['POST' ])
122122@login_required
123123def disable_2fa ():
124- """Disable 2FA for user"""
124+ """Disable 2FA for current user"""
125125 try :
126126 print (f"Disabling 2FA for user: { current_user .username } " )
127127
128+ # Disable 2FA
128129 current_user .totp_enabled = False
129130 current_user .totp_secret = None
131+
130132 db .session .commit ()
131133
132- flash ('2FA has been disabled' , 'success' )
134+ flash ('Two-factor authentication has been disabled. ' , 'success' )
133135 return redirect (url_for ('auth.profile' ))
134136
135137 except Exception as e :
136- print (f"ERROR in disable_2fa: { str (e )} " )
137- flash ('An error occurred while disabling 2FA' , 'error' )
138+ print (f"Error disabling 2FA: { e } " )
139+ import traceback
140+ traceback .print_exc ()
141+
142+ db .session .rollback ()
143+ flash ('Error disabling 2FA. Please try again.' , 'error' )
138144 return redirect (url_for ('auth.profile' ))
139145
146+
140147def generate_qr_code (user ):
141148 """Generate QR code for TOTP setup"""
142149 try :
You can’t perform that action at this time.
0 commit comments