File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -1271,22 +1271,27 @@ func GetUser(user *User) (bool, error) {
1271
1271
1272
1272
// SearchUserOptions contains the options for searching
1273
1273
type SearchUserOptions struct {
1274
- Keyword string
1275
- Type UserType
1276
- OrderBy string
1277
- Page int
1278
- PageSize int // Can be smaller than or equal to setting.UI.ExplorePagingNum
1279
- IsActive util.OptionalBool
1274
+ Keyword string
1275
+ Type UserType
1276
+ OrderBy string
1277
+ Page int
1278
+ PageSize int // Can be smaller than or equal to setting.UI.ExplorePagingNum
1279
+ IsActive util.OptionalBool
1280
+ SearchByEmail bool // Search by email as well as username/full name
1280
1281
}
1281
1282
1282
1283
func (opts * SearchUserOptions ) toConds () builder.Cond {
1283
1284
var cond builder.Cond = builder.Eq {"type" : opts .Type }
1284
1285
if len (opts .Keyword ) > 0 {
1285
1286
lowerKeyword := strings .ToLower (opts .Keyword )
1286
- cond = cond . And ( builder .Or (
1287
+ keywordCond := builder .Or (
1287
1288
builder.Like {"lower_name" , lowerKeyword },
1288
1289
builder.Like {"LOWER(full_name)" , lowerKeyword },
1289
- ))
1290
+ )
1291
+ if opts .SearchByEmail {
1292
+ keywordCond = keywordCond .Or (builder.Like {"LOWER(email)" , lowerKeyword })
1293
+ }
1294
+ cond = cond .And (keywordCond )
1290
1295
}
1291
1296
1292
1297
if ! opts .IsActive .IsNone () {
Original file line number Diff line number Diff line change @@ -31,8 +31,9 @@ func Users(ctx *context.Context) {
31
31
ctx .Data ["PageIsAdminUsers" ] = true
32
32
33
33
routers .RenderUserSearch (ctx , & models.SearchUserOptions {
34
- Type : models .UserTypeIndividual ,
35
- PageSize : setting .UI .Admin .UserPagingNum ,
34
+ Type : models .UserTypeIndividual ,
35
+ PageSize : setting .UI .Admin .UserPagingNum ,
36
+ SearchByEmail : true ,
36
37
}, tplUsers )
37
38
}
38
39
You can’t perform that action at this time.
0 commit comments