File tree Expand file tree Collapse file tree
apps/server/src/database/repos/user-mfa Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments