Skip to content

Commit c4d2382

Browse files
committed
Merge branch 'main' into lunny/move_admin_router
2 parents 8c71530 + 6a4eb12 commit c4d2382

File tree

6 files changed

+1878
-9
lines changed

6 files changed

+1878
-9
lines changed

models/user/search.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,19 @@ func (opts *SearchUserOptions) toSearchQueryBase(ctx context.Context) *xorm.Sess
6565
builder.Like{"LOWER(full_name)", lowerKeyword},
6666
)
6767
if opts.SearchByEmail {
68-
keywordCond = keywordCond.Or(builder.Like{"LOWER(email)", lowerKeyword})
68+
var emailCond builder.Cond
69+
emailCond = builder.Like{"LOWER(email)", lowerKeyword}
70+
if opts.Actor == nil {
71+
emailCond = emailCond.And(builder.Eq{"keep_email_private": false})
72+
} else if !opts.Actor.IsAdmin {
73+
emailCond = emailCond.And(
74+
builder.Or(
75+
builder.Eq{"keep_email_private": false},
76+
builder.Eq{"id": opts.Actor.ID},
77+
),
78+
)
79+
}
80+
keywordCond = keywordCond.Or(emailCond)
6981
}
7082

7183
cond = cond.And(keywordCond)

0 commit comments

Comments
 (0)