1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-28 09:21:13 -05:00

Merge pull request '[gitea] week 2024-44-v9.0 cherry pick (gitea/main -> v9.0/forgejo)' (#5715) from earl-warren/wcp/2024-44-v9.0 into v9.0/forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5715
This commit is contained in:
Earl Warren 2024-10-28 06:59:58 +00:00
commit ff585d0a20
3 changed files with 8 additions and 3 deletions

1
release-notes/5715.md Normal file
View file

@ -0,0 +1 @@
fix: [commit](https://codeberg.org/forgejo/forgejo/commit/768402c8841db5e8acc97919149ba329d5124e17) Fix disable 2fa bug

View file

@ -34,8 +34,9 @@ func RegenerateScratchTwoFactor(ctx *context.Context) {
if auth.IsErrTwoFactorNotEnrolled(err) { if auth.IsErrTwoFactorNotEnrolled(err) {
ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled")) ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled"))
ctx.Redirect(setting.AppSubURL + "/user/settings/security") ctx.Redirect(setting.AppSubURL + "/user/settings/security")
} } else {
ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err) ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err)
}
return return
} }
@ -64,8 +65,9 @@ func DisableTwoFactor(ctx *context.Context) {
if auth.IsErrTwoFactorNotEnrolled(err) { if auth.IsErrTwoFactorNotEnrolled(err) {
ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled")) ctx.Flash.Error(ctx.Tr("settings.twofa_not_enrolled"))
ctx.Redirect(setting.AppSubURL + "/user/settings/security") ctx.Redirect(setting.AppSubURL + "/user/settings/security")
} } else {
ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err) ctx.ServerError("SettingsTwoFactor: Failed to GetTwoFactorByUID", err)
}
return return
} }
@ -74,8 +76,9 @@ func DisableTwoFactor(ctx *context.Context) {
// There is a potential DB race here - we must have been disabled by another request in the intervening period // There is a potential DB race here - we must have been disabled by another request in the intervening period
ctx.Flash.Success(ctx.Tr("settings.twofa_disabled")) ctx.Flash.Success(ctx.Tr("settings.twofa_disabled"))
ctx.Redirect(setting.AppSubURL + "/user/settings/security") ctx.Redirect(setting.AppSubURL + "/user/settings/security")
} } else {
ctx.ServerError("SettingsTwoFactor: Failed to DeleteTwoFactorByID", err) ctx.ServerError("SettingsTwoFactor: Failed to DeleteTwoFactorByID", err)
}
return return
} }

View file

@ -306,6 +306,7 @@ func DeleteInactiveUsers(ctx context.Context, olderThan time.Duration) error {
// Ignore users that were set inactive by admin. // Ignore users that were set inactive by admin.
if models.IsErrUserOwnRepos(err) || models.IsErrUserHasOrgs(err) || if models.IsErrUserOwnRepos(err) || models.IsErrUserHasOrgs(err) ||
models.IsErrUserOwnPackages(err) || models.IsErrDeleteLastAdminUser(err) { models.IsErrUserOwnPackages(err) || models.IsErrDeleteLastAdminUser(err) {
log.Warn("Inactive user %q has repositories, organizations or packages, skipping deletion: %v", u.Name, err)
continue continue
} }
return err return err