1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-08-08 22:36:41 +02:00

issue#7 fix applyClaimsSelect when empty conditions

When audience and subject are both empty, don't apply a subquery
This commit is contained in:
Lee Brown
2019-07-15 16:05:02 -08:00
parent 4867b207f2
commit 72ef940eb1
4 changed files with 12 additions and 8 deletions

View File

@ -87,10 +87,12 @@ func applyClaimsSelect(ctx context.Context, claims auth.Claims, query *sqlbuilde
if claims.Subject != "" {
or = append(or, subQuery.Equal("user_id", claims.Subject))
}
subQuery.Where(subQuery.Or(or...))
// Append sub query
query.Where(query.In("id", subQuery))
if len(or) > 0 {
subQuery.Where(subQuery.Or(or...))
query.Where(query.In("id", subQuery))
}
return nil
}