summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
author花墨 <shanee@live.com>2022-11-30 17:00:00 +0800
committerGitHub <noreply@github.com>2022-11-30 17:00:00 +0800
commit7020c4afb74756f60ae5381a05c6511dbf0d72ba (patch)
treeb43fff7c244a9ac5aeca17336adf7fecd3cb24ba /routers
parentfdfd77f478c40c83131b08b2ee27545790e454d0 (diff)
downloadgitea-7020c4afb74756f60ae5381a05c6511dbf0d72ba.tar.gz
gitea-7020c4afb74756f60ae5381a05c6511dbf0d72ba.zip
Fix leaving organization bug on user settings -> orgs (#21983)
Fix #21772 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/org/members.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/routers/web/org/members.go b/routers/web/org/members.go
index 3be2a39c2e..8361da6632 100644
--- a/routers/web/org/members.go
+++ b/routers/web/org/members.go
@@ -107,13 +107,20 @@ func MembersAction(ctx *context.Context) {
}
case "leave":
err = models.RemoveOrgUser(org.ID, ctx.Doer.ID)
- if organization.IsErrLastOrgOwner(err) {
+ if err == nil {
+ ctx.Flash.Success(ctx.Tr("form.organization_leave_success", org.DisplayName()))
+ ctx.JSON(http.StatusOK, map[string]interface{}{
+ "redirect": "", // keep the user stay on current page, in case they want to do other operations.
+ })
+ } else if organization.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
ctx.JSON(http.StatusOK, map[string]interface{}{
"redirect": ctx.Org.OrgLink + "/members",
})
- return
+ } else {
+ log.Error("RemoveOrgUser(%d,%d): %v", org.ID, ctx.Doer.ID, err)
}
+ return
}
if err != nil {