diff options
author | zeripath <art27@cantab.net> | 2022-07-14 08:22:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-14 08:22:09 +0100 |
commit | bffa30302070b594a1c40cdc56264b9731036fb3 (patch) | |
tree | 92104ff6b8a51f5d1506742427dd1399fa42428c /routers/web/admin/users.go | |
parent | 175705356cac06c22d13d86b31605a6ad6dd9642 (diff) | |
download | gitea-bffa30302070b594a1c40cdc56264b9731036fb3.tar.gz gitea-bffa30302070b594a1c40cdc56264b9731036fb3.zip |
Add option to purge users (#18064)
Add the ability to purge users when deleting them.
Close #15588
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers/web/admin/users.go')
-rw-r--r-- | routers/web/admin/users.go | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index c37ecfd71e..aab633ec84 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -419,29 +419,21 @@ func DeleteUser(ctx *context.Context) { // admin should not delete themself if u.ID == ctx.Doer.ID { ctx.Flash.Error(ctx.Tr("admin.users.cannot_delete_self")) - ctx.JSON(http.StatusOK, map[string]interface{}{ - "redirect": setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid")), - }) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid"))) return } - if err = user_service.DeleteUser(u); err != nil { + if err = user_service.DeleteUser(ctx, u, ctx.FormBool("purge")); err != nil { switch { case models.IsErrUserOwnRepos(err): ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo")) - ctx.JSON(http.StatusOK, map[string]interface{}{ - "redirect": setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid")), - }) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid"))) case models.IsErrUserHasOrgs(err): ctx.Flash.Error(ctx.Tr("admin.users.still_has_org")) - ctx.JSON(http.StatusOK, map[string]interface{}{ - "redirect": setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid")), - }) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid"))) case models.IsErrUserOwnPackages(err): ctx.Flash.Error(ctx.Tr("admin.users.still_own_packages")) - ctx.JSON(http.StatusOK, map[string]interface{}{ - "redirect": setting.AppSubURL + "/admin/users/" + ctx.Params(":userid"), - }) + ctx.Redirect(setting.AppSubURL + "/admin/users/" + ctx.Params(":userid")) default: ctx.ServerError("DeleteUser", err) } @@ -450,9 +442,7 @@ func DeleteUser(ctx *context.Context) { log.Trace("Account deleted by admin (%s): %s", ctx.Doer.Name, u.Name) ctx.Flash.Success(ctx.Tr("admin.users.deletion_success")) - ctx.JSON(http.StatusOK, map[string]interface{}{ - "redirect": setting.AppSubURL + "/admin/users", - }) + ctx.Redirect(setting.AppSubURL + "/admin/users") } // AvatarPost response for change user's avatar request |