summaryrefslogtreecommitdiffstats
path: root/routers/web/org/members.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2023-01-15 23:29:27 +0000
committerGitHub <noreply@github.com>2023-01-16 01:29:27 +0200
commitf430050d244f8bbefc0726b786d49b70bf6a8234 (patch)
treeaa459cc071a21454899550fa9d827e0e5a0bee20 /routers/web/org/members.go
parent510c811574f035470ef0acf455e015e76a716f58 (diff)
downloadgitea-f430050d244f8bbefc0726b786d49b70bf6a8234.tar.gz
gitea-f430050d244f8bbefc0726b786d49b70bf6a8234.zip
Fix leaving organization bug on user settings -> orgs (#21983) (#22438)
Backport #21983 Fix #21772 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: 花墨 <shanee@live.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'routers/web/org/members.go')
-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 ec5a98fc6a..6aeff57071 100644
--- a/routers/web/org/members.go
+++ b/routers/web/org/members.go
@@ -108,13 +108,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 {