Skip to content

Commit b7c82cd

Browse files
authored
Fix orgs not being displayed on create repo form (#11279)
1 parent ce66ca7 commit b7c82cd

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

routers/repo/repo.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
6262
return nil
6363
}
6464

65+
if !ctx.User.IsAdmin {
66+
orgsAvailable := []*models.User{}
67+
for i := 0; i < len(orgs); i++ {
68+
if orgs[i].CanCreateRepo() {
69+
orgsAvailable = append(orgsAvailable, orgs[i])
70+
}
71+
}
72+
ctx.Data["Orgs"] = orgsAvailable
73+
} else {
74+
ctx.Data["Orgs"] = orgs
75+
}
76+
6577
// Not equal means current user is an organization.
6678
if uid == ctx.User.ID || uid == 0 {
6779
return ctx.User
@@ -83,14 +95,6 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
8395
return nil
8496
}
8597
if !ctx.User.IsAdmin {
86-
orgsAvailable := []*models.User{}
87-
for i := 0; i < len(orgs); i++ {
88-
if orgs[i].CanCreateRepo() {
89-
orgsAvailable = append(orgsAvailable, orgs[i])
90-
}
91-
}
92-
ctx.Data["Orgs"] = orgsAvailable
93-
9498
canCreate, err := org.CanCreateOrgRepo(ctx.User.ID)
9599
if err != nil {
96100
ctx.ServerError("CanCreateOrgRepo", err)

0 commit comments

Comments
 (0)