mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 03:47:55 +01:00
#1633 admin delete user
This commit is contained in:
parent
5f1183cecf
commit
2d1bb0cf49
@ -797,6 +797,7 @@ users.update_profile = Update Account Profile
|
||||
users.delete_account = Delete This Account
|
||||
users.still_own_repo = This account still has ownership over at least one repository, you have to delete or transfer them first.
|
||||
users.still_has_org = This account still has membership in at least one organization, you have to leave or delete the organizations first.
|
||||
users.deletion_success = Account has been deleted successfully!
|
||||
|
||||
orgs.org_manage_panel = Organization Manage Panel
|
||||
orgs.name = Name
|
||||
|
@ -670,7 +670,8 @@ func DeleteUser(u *User) (err error) {
|
||||
}
|
||||
|
||||
if err = deleteUser(sess, u); err != nil {
|
||||
return fmt.Errorf("deleteUser: %v", err)
|
||||
// Note: don't wrapper error here.
|
||||
return err
|
||||
}
|
||||
|
||||
return sess.Commit()
|
||||
|
File diff suppressed because one or more lines are too long
@ -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",
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user