diff options
author | Unknwon <u@gogs.io> | 2015-09-13 13:26:20 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-09-13 13:26:20 -0400 |
commit | 2d1bb0cf49766e1acf5d3da824dee514ada6ff9d (patch) | |
tree | 7e03d99a2d1547a39b80d377d1b65c8836706fd5 /routers | |
parent | 5f1183cecf4f3c6bf677369c4e2a2788b795ab15 (diff) | |
download | gitea-2d1bb0cf49766e1acf5d3da824dee514ada6ff9d.tar.gz gitea-2d1bb0cf49766e1acf5d3da824dee514ada6ff9d.zip |
#1633 admin delete user
Diffstat (limited to 'routers')
-rw-r--r-- | routers/admin/users.go | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go index b04cfc13bd..4302c1443b 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -220,13 +220,7 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) { } func DeleteUser(ctx *middleware.Context) { - uid := com.StrTo(ctx.Params(":userid")).MustInt64() - if uid == 0 { - ctx.Handle(404, "DeleteUser", nil) - return - } - - u, err := models.GetUserByID(uid) + u, err := models.GetUserByID(ctx.ParamsInt64(":userid")) if err != nil { ctx.Handle(500, "GetUserByID", err) return @@ -236,15 +230,23 @@ func DeleteUser(ctx *middleware.Context) { switch { case models.IsErrUserOwnRepos(err): ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo")) - ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) + ctx.JSON(200, map[string]interface{}{ + "redirect": setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid"), + }) case models.IsErrUserHasOrgs(err): ctx.Flash.Error(ctx.Tr("admin.users.still_has_org")) - ctx.Redirect(setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid")) + ctx.JSON(200, map[string]interface{}{ + "redirect": setting.AppSubUrl + "/admin/users/" + ctx.Params(":userid"), + }) default: ctx.Handle(500, "DeleteUser", err) } return } log.Trace("Account deleted by admin(%s): %s", ctx.User.Name, u.Name) - ctx.Redirect(setting.AppSubUrl + "/admin/users") + + ctx.Flash.Success(ctx.Tr("admin.users.deletion_success")) + ctx.JSON(200, map[string]interface{}{ + "redirect": setting.AppSubUrl + "/admin/users", + }) } |