summaryrefslogtreecommitdiffstats
path: root/routers/repo/setting.go
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-12-20 23:43:26 -0800
committerLauris BH <lauris@nix.lv>2017-12-21 09:43:26 +0200
commit515cdaa85d6087d91a61ebe74fae39e0c4bdf1c4 (patch)
tree3a7143fc376af4402ca9008876be3afdc0c18efc /routers/repo/setting.go
parent529482135c8e9304dd7cdf08772eaba61d903894 (diff)
downloadgitea-515cdaa85d6087d91a61ebe74fae39e0c4bdf1c4.tar.gz
gitea-515cdaa85d6087d91a61ebe74fae39e0c4bdf1c4.zip
Fix ignored errors when checking if organization, team member (#3177)
Diffstat (limited to 'routers/repo/setting.go')
-rw-r--r--routers/repo/setting.go42
1 files changed, 10 insertions, 32 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 329802673d..8cb551707c 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -234,13 +234,6 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
return
}
- if ctx.Repo.Owner.IsOrganization() {
- if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) {
- ctx.Error(404)
- return
- }
- }
-
if !repo.IsMirror {
ctx.Error(404)
return
@@ -268,13 +261,6 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
return
}
- if ctx.Repo.Owner.IsOrganization() {
- if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) {
- ctx.Error(404)
- return
- }
- }
-
newOwner := ctx.Query("new_owner_name")
isExist, err := models.IsUserExist(0, newOwner)
if err != nil {
@@ -307,13 +293,6 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
return
}
- if ctx.Repo.Owner.IsOrganization() {
- if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) {
- ctx.Error(404)
- return
- }
- }
-
if err := models.DeleteRepository(ctx.User, ctx.Repo.Owner.ID, repo.ID); err != nil {
ctx.Handle(500, "DeleteRepository", err)
return
@@ -333,13 +312,6 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
return
}
- if ctx.Repo.Owner.IsOrganization() {
- if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) {
- ctx.Error(404)
- return
- }
- }
-
repo.DeleteWiki()
log.Trace("Repository wiki deleted: %s/%s", ctx.Repo.Owner.Name, repo.Name)
@@ -393,10 +365,16 @@ func CollaborationPost(ctx *context.Context) {
}
// Check if user is organization member.
- if ctx.Repo.Owner.IsOrganization() && ctx.Repo.Owner.IsOrgMember(u.ID) {
- ctx.Flash.Info(ctx.Tr("repo.settings.user_is_org_member"))
- ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
- return
+ if ctx.Repo.Owner.IsOrganization() {
+ isMember, err := ctx.Repo.Owner.IsOrgMember(u.ID)
+ if err != nil {
+ ctx.Handle(500, "IsOrgMember", err)
+ return
+ } else if isMember {
+ ctx.Flash.Info(ctx.Tr("repo.settings.user_is_org_member"))
+ ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
+ return
+ }
}
if err = ctx.Repo.Repository.AddCollaborator(u); err != nil {