summaryrefslogtreecommitdiffstats
path: root/routers/repo/setting.go
diff options
context:
space:
mode:
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 {