@@ -423,15 +423,10 @@ const findUsersWithAuthData = async (config, authData, beforeFind) => {
423
423
const queries = await Promise . all (
424
424
providers . map ( async provider => {
425
425
const providerAuthData = authData [ provider ] ;
426
- if ( ! providerAuthData ) {
427
- return null ;
428
- }
429
426
430
- if ( beforeFind ) {
431
- const adapter = config . authDataManager . getValidatorForProvider ( provider ) ?. adapter ;
432
- if ( typeof adapter ?. beforeFind === 'function' ) {
433
- await adapter . beforeFind ( providerAuthData ) ;
434
- }
427
+ const adapter = config . authDataManager . getValidatorForProvider ( provider ) ?. adapter ;
428
+ if ( beforeFind && typeof adapter ?. beforeFind === 'function' ) {
429
+ await adapter . beforeFind ( providerAuthData ) ;
435
430
}
436
431
437
432
if ( ! providerAuthData ?. id ) {
@@ -606,70 +601,6 @@ const handleAuthDataValidation = async (authData, req, foundUser) => {
606
601
return acc ;
607
602
} ;
608
603
609
- const subsetEqual = ( prev , next ) => {
610
- if ( prev === next ) return true ;
611
- if ( prev == null || next == null ) return false ;
612
-
613
- const tp = typeof prev ;
614
- const tn = typeof next ;
615
- if ( tn !== 'object' || tp !== 'object' ) return prev === next ;
616
-
617
- // arrays: require element-wise equality for the provided portion
618
- if ( Array . isArray ( next ) ) {
619
- if ( ! Array . isArray ( prev ) ) return false ;
620
- if ( next . length !== prev . length ) return false ;
621
- for ( let i = 0 ; i < next . length ; i ++ ) {
622
- if ( ! subsetEqual ( prev [ i ] , next [ i ] ) ) return false ;
623
- }
624
- return true ;
625
- }
626
-
627
- // objects: every provided key in `next` must match `prev`
628
- for ( const k of Object . keys ( next ) ) {
629
- const nv = next [ k ] ;
630
- if ( typeof nv === 'undefined' ) continue ; // treat "not provided" as no-op
631
- const pv = prev [ k ] ;
632
- if ( ! subsetEqual ( pv , nv ) ) return false ;
633
- }
634
- return true ;
635
- }
636
-
637
- /**
638
- * Delta between current and incoming authData with partial update semantics:
639
- * - changed: providers truly changed (new or value differs on provided keys)
640
- * - unlink: providers explicitly set to null (remove without validation)
641
- * - unchanged: providers either absent in incoming or provided as matching subset
642
- */
643
- const diffAuthData = ( current = { } , incoming = { } ) => {
644
- const changed = { } ;
645
- const unlink = { } ;
646
- const unchanged = { } ;
647
-
648
- const providers = new Set ( [ ...Object . keys ( current ) , ...Object . keys ( incoming ) ] ) ;
649
- for ( const p of providers ) {
650
- const prev = current [ p ] ;
651
- const next = incoming [ p ] ;
652
-
653
- if ( next === null ) { unlink [ p ] = true ; continue ; }
654
- if ( typeof next === 'undefined' ) { // provider untouched
655
- if ( typeof prev !== 'undefined' ) unchanged [ p ] = prev ;
656
- continue ;
657
- }
658
- if ( typeof prev === 'undefined' ) { // new provider
659
- changed [ p ] = next ;
660
- continue ;
661
- }
662
-
663
- // key point: treat sanitized partial payload (subset) as unchanged
664
- if ( subsetEqual ( prev , next ) ) {
665
- unchanged [ p ] = prev ;
666
- } else {
667
- changed [ p ] = next ;
668
- }
669
- }
670
- return { changed, unlink, unchanged } ;
671
- } ;
672
-
673
604
module . exports = {
674
605
Auth,
675
606
master,
@@ -683,6 +614,4 @@ module.exports = {
683
614
hasMutatedAuthData,
684
615
checkIfUserHasProvidedConfiguredProvidersForLogin,
685
616
handleAuthDataValidation,
686
- subsetEqual,
687
- diffAuthData
688
617
} ;
0 commit comments