chore(core): Expose mfaEnabled field to users list endpoint (#16654)

This commit is contained in:
Andreas Fitzek
2025-06-24 14:21:43 +02:00
committed by GitHub
parent bc53c21e15
commit c4a50df824
5 changed files with 74 additions and 3 deletions

View File

@@ -182,6 +182,12 @@ export class UserRepository extends Repository<User> {
});
}
if (filter?.mfaEnabled !== undefined) {
queryBuilder.andWhere('user.mfaEnabled = :mfaEnabled', {
mfaEnabled: filter.mfaEnabled,
});
}
if (filter?.isOwner !== undefined) {
if (filter.isOwner) {
queryBuilder.andWhere('user.role = :role', {
@@ -240,13 +246,13 @@ export class UserRepository extends Repository<User> {
if (sortBy) {
for (const sort of sortBy) {
const [field, order] = sort.split(':');
if (field === 'firstName' || field === 'lastName') {
queryBuilder.addOrderBy(`user.${field}`, order.toUpperCase() as 'ASC' | 'DESC');
} else if (field === 'role') {
if (field === 'role') {
queryBuilder.addOrderBy(
"CASE WHEN user.role='global:owner' THEN 0 WHEN user.role='global:admin' THEN 1 ELSE 2 END",
order.toUpperCase() as 'ASC' | 'DESC',
);
} else {
queryBuilder.addOrderBy(`user.${field}`, order.toUpperCase() as 'ASC' | 'DESC');
}
}
}