File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
packages/core/src/routes/experience/classes Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -316,7 +316,25 @@ export class Mfa {
316316 return ;
317317 }
318318
319- const additionalFactors = availableFactors . filter ( ( factor ) => ! factorsInUser . includes ( factor ) ) ;
319+ const additionalFactors = availableFactors
320+ . filter ( ( factor ) => ! factorsInUser . includes ( factor ) )
321+ . slice ( )
322+ . sort ( ( factorA , factorB ) => {
323+ // Sort order: webauthn -> totp -> sms -> email -> backup code
324+ const order = [
325+ MfaFactor . WebAuthn ,
326+ MfaFactor . TOTP ,
327+ MfaFactor . PhoneVerificationCode ,
328+ MfaFactor . EmailVerificationCode ,
329+ MfaFactor . BackupCode ,
330+ ] ;
331+
332+ const indexA = order . indexOf ( factorA ) ;
333+ const indexB = order . indexOf ( factorB ) ;
334+
335+ // Unrecognized factors at the end
336+ return ( indexA === - 1 ? order . length : indexA ) - ( indexB === - 1 ? order . length : indexB ) ;
337+ } ) ;
320338
321339 // Respect user's choice to skip suggestion for this interaction
322340 if ( this . additionalBindingSuggestionSkipped ) {
You can’t perform that action at this time.
0 commit comments