allow JL5 to search users by email

master
Aevann 2024-04-07 06:35:20 +02:00
parent a595824d94
commit 9db575ae93
1 changed files with 10 additions and 9 deletions

View File

@ -403,17 +403,18 @@ def searchusers(v):
if 'q' in criteria:
term = criteria['q'][0]
term = sanitize_username(term)
users = users.filter(
or_(
User.username.ilike(f'%{term}%'),
User.original_username.ilike(f'%{term}%'),
User.extra_username.ilike(f'%{term}%'),
User.prelock_username.ilike(f'%{term}%'),
)
).order_by(User.username.ilike(term).desc(), User.stored_subscriber_count.desc())
or_criteria = [
User.username.ilike(f'%{term}%'),
User.original_username.ilike(f'%{term}%'),
User.extra_username.ilike(f'%{term}%'),
User.prelock_username.ilike(f'%{term}%'),
]
if v.admin_level >= PERMS['VIEW_EMAILS']:
or_criteria.append(User.email.ilike(f'%{term}%'))
users = users.filter(or_(*or_criteria)).order_by(User.username.ilike(term).desc(), User.stored_subscriber_count.desc())
total = users.count()