Skip to content

Commit 4359288

Browse files
committed
Fix bug
1 parent 43d75c0 commit 4359288

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

models/org.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,18 +529,22 @@ type FindOrgOptions struct {
529529
func (opts FindOrgOptions) toConds() builder.Cond {
530530
var cond = builder.NewCond()
531531
if opts.UserID > 0 {
532-
cond = cond.And(builder.Eq{"`org_user`.uid": opts.UserID})
532+
cond = cond.And(builder.In("`user`.`id`", queryUserOrgIDs(opts.UserID)))
533533
}
534534
if !opts.IncludePrivate {
535535
cond = cond.And(builder.Eq{"`user`.visibility": structs.VisibleTypePublic})
536+
} else {
537+
cond = cond.And(builder.Eq{"`user`.visibility": structs.VisibleTypePrivate}.Or(
538+
builder.Eq{"`user`.visibility": structs.VisibleTypeLimited},
539+
))
536540
}
537541
return cond
538542
}
539543

540544
// FindOrgs returns a list of organizations according given conditions
541545
func FindOrgs(opts FindOrgOptions) ([]*User, error) {
542546
orgs := make([]*User, 0, 10)
543-
sess := db.GetEngine(db.DefaultContext).Join("INNER", "`org_user`", "`org_user`.org_id=`user`.id").
547+
sess := db.GetEngine(db.DefaultContext).
544548
Where(opts.toConds()).
545549
Asc("`user`.name")
546550
if opts.Page > 0 && opts.PageSize > 0 {

0 commit comments

Comments
 (0)