File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
components/server/src/auth Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,16 @@ export class AuthProviderService {
31
31
const transformed = all . map ( this . toAuthProviderParams . bind ( this ) ) ;
32
32
33
33
// as a precaution, let's remove duplicates
34
- const unique = transformed . reduce ( ( prev , current ) => {
35
- const duplicate = prev . some ( a => a . host === current . host ) ;
34
+ const unique = new Map < string , AuthProviderParams > ( ) ;
35
+ for ( const current of transformed ) {
36
+ const duplicate = unique . get ( current . host ) ;
36
37
if ( duplicate ) {
37
38
log . warn ( `Duplicate dynamic Auth Provider detected.` , { rawResult : all , duplicate : current . host } ) ;
39
+ continue ;
38
40
}
39
- return duplicate ? prev : [ ... prev , current ] ;
40
- } , [ ] as AuthProviderParams [ ] ) ;
41
- return unique ;
41
+ unique . set ( current . host , current ) ;
42
+ }
43
+ return Array . from ( unique . values ( ) ) ;
42
44
}
43
45
44
46
protected toAuthProviderParams = ( oap : AuthProviderEntry ) => < AuthProviderParams > {
You can’t perform that action at this time.
0 commit comments