{{$.locale.Tr "org.members.leave.detail" `` | Safe}}
+diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index eb2a1c86dbbf1..94f58e483338b 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -501,6 +501,7 @@ team_not_exist = The team does not exist. last_org_owner = You cannot remove the last user from the 'owners' team. There must be at least one owner for an organization. cannot_add_org_to_team = An organization cannot be added as a team member. duplicate_invite_to_team = The user was already invited as a team member. +organization_leave_success=You have successfully left the organization %s. invalid_ssh_key = Can not verify your SSH key: %s invalid_gpg_key = Can not verify your GPG key: %s diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index ee6f686a85795..6ccbd7b871fc6 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -499,6 +499,7 @@ team_not_exist=团队不存在 last_org_owner=您不能从 "所有者" 团队中删除最后一个用户。组织中必须至少有一个所有者。 cannot_add_org_to_team=组织不能被加入到团队中。 duplicate_invite_to_team=此用户已被邀请为团队成员。 +organization_leave_success=您已成功离开组织:%s。 invalid_ssh_key=无法验证您的 SSH 密钥: %s invalid_gpg_key=无法验证您的 GPG 密钥: %s diff --git a/options/locale/locale_zh-TW.ini b/options/locale/locale_zh-TW.ini index ff2a238fa0227..257ab0e183430 100644 --- a/options/locale/locale_zh-TW.ini +++ b/options/locale/locale_zh-TW.ini @@ -488,6 +488,7 @@ user_not_exist=該用戶名不存在 team_not_exist=團隊不存在 last_org_owner=你不能從「Owners」團隊中刪除最後一個使用者。每個組織中至少要有一個擁有者。 cannot_add_org_to_team=組織不能被新增為團隊成員。 +organization_leave_success=您已成功離開組織:%s。 invalid_ssh_key=無法驗證您的 SSH 密鑰:%s invalid_gpg_key=無法驗證您的 GPG 密鑰:%s diff --git a/routers/web/org/members.go b/routers/web/org/members.go index ec5a98fc6a240..a2def2ae34406 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": "", + }) + } 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 { diff --git a/templates/user/settings/organization.tmpl b/templates/user/settings/organization.tmpl index e25d5e7fa6766..703ac8ad8edbe 100644 --- a/templates/user/settings/organization.tmpl +++ b/templates/user/settings/organization.tmpl @@ -17,9 +17,13 @@ {{range .Orgs}}
{{$.locale.Tr "org.members.leave.detail" `` | Safe}}
+