Skip to content

Commit dab1fce

Browse files
committed
Fix bug
1 parent 77efa45 commit dab1fce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: models/org.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -454,18 +454,22 @@ type FindOrgOptions struct {
454454
func (opts FindOrgOptions) toConds() builder.Cond {
455455
var cond = builder.NewCond()
456456
if opts.UserID > 0 {
457-
cond = cond.And(builder.Eq{"`org_user`.uid": opts.UserID})
457+
cond = cond.And(builder.In("`user`.`id`", queryUserOrgIDs(opts.UserID)))
458458
}
459459
if !opts.IncludePrivate {
460460
cond = cond.And(builder.Eq{"`user`.visibility": structs.VisibleTypePublic})
461+
} else {
462+
cond = cond.And(builder.Eq{"`user`.visibility": structs.VisibleTypePrivate}.Or(
463+
builder.Eq{"`user`.visibility": structs.VisibleTypeLimited},
464+
))
461465
}
462466
return cond
463467
}
464468

465469
// FindOrgs returns a list of organizations according given conditions
466470
func FindOrgs(opts FindOrgOptions) ([]*User, error) {
467471
orgs := make([]*User, 0, 10)
468-
sess := x.Join("INNER", "`org_user`", "`org_user`.org_id=`user`.id").
472+
sess := x.
469473
Where(opts.toConds()).
470474
Asc("`user`.name")
471475
if opts.Page > 0 && opts.PageSize > 0 {

0 commit comments

Comments
 (0)