Skip to content

Commit 44cbb73

Browse files
authored
Merge pull request #7 from CHIPAsia/mfa_fix
Fix issue with mfa on user view
2 parents 2ce6e53 + 93fcf4d commit 44cbb73

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

apps/server/src/database/repos/user-mfa/user-mfa.repo.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,15 @@ export class UserMfaRepo {
7272
trx?: KyselyTransaction,
7373
): Promise<Array<{ userId: string; isEnabled: boolean | null }>> {
7474
const db = dbOrTx(this.db, trx);
75+
// Join with users to get MFA status for workspace members.
76+
// user_mfa has unique constraint on user_id only, so one user has one MFA record.
77+
// We match by workspace members (users.workspace_id) rather than user_mfa.workspace_id,
78+
// since the MFA record's workspace_id may differ from the viewed workspace.
7579
const rows = await db
7680
.selectFrom('userMfa')
77-
.select(['userId', 'isEnabled'])
78-
.where('workspaceId', '=', workspaceId)
81+
.innerJoin('users', 'users.id', 'userMfa.userId')
82+
.select(['userMfa.userId', 'userMfa.isEnabled'])
83+
.where('users.workspaceId', '=', workspaceId)
7984
.execute();
8085
return rows;
8186
}

0 commit comments

Comments
 (0)