Skip to content

Commit b6a7c51

Browse files
committed
Fix disable 2fa bug (go-gitea#32320)
1 parent 0d11ba9 commit b6a7c51

File tree

1 file changed

+6
-3
lines changed
  • routers/web/user/setting/security

1 file changed

+6
-3
lines changed

routers/web/user/setting/security/2fa.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ func RegenerateScratchTwoFactor(ctx *context.Context) {
3333
if auth.IsErrTwoFactorNotEnrolled(err) {
3434
ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled"))
3535
ctx.Redirect(setting.AppSubURL + "/user/settings/security")
36+
} else {
37+
ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err)
3638
}
37-
ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err)
3839
return
3940
}
4041

@@ -63,8 +64,9 @@ func DisableTwoFactor(ctx *context.Context) {
6364
if auth.IsErrTwoFactorNotEnrolled(err) {
6465
ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled"))
6566
ctx.Redirect(setting.AppSubURL + "/user/settings/security")
67+
} else {
68+
ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err)
6669
}
67-
ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err)
6870
return
6971
}
7072

@@ -73,8 +75,9 @@ func DisableTwoFactor(ctx *context.Context) {
7375
// There is a potential DB race here - we must have been disabled by another request in the intervening period
7476
ctx.Flash.Success(ctx.Tr("settings.twofa_disabled"))
7577
ctx.Redirect(setting.AppSubURL + "/user/settings/security")
78+
} else {
79+
ctx.ServerError("SettingsTwoFactor: Failed to DeleteTwoFactorByID", err)
7680
}
77-
ctx.ServerError("SettingsTwoFactor: Failed to DeleteTwoFactorByID", err)
7881
return
7982
}
8083

0 commit comments

Comments
 (0)