@@ -14,7 +14,7 @@ import GluuLoader from '@/routes/Apps/Gluu/GluuLoader'
1414import { ThemeContext } from '@/context/theme/themeContext'
1515import DefaultAcrInput from '../Configuration/DefaultAcrInput'
1616import { getScripts } from 'Redux/features/initSlice'
17- import { SIMPLE_PASSWORD_AUTH } from 'Plugins/auth-server/common/Constants '
17+ import { buildAgamaFlowsArray , buildDropdownOptions } from './helper/acrUtils '
1818
1919function DefaultAcr ( ) {
2020 const { hasCedarPermission, authorize } = useCedarling ( )
@@ -52,19 +52,17 @@ function DefaultAcr() {
5252 } , [ authorize , dispatch ] )
5353
5454 const authScripts = useMemo ( ( ) => {
55+ // Filter and map scripts
5556 const filteredScripts = scripts
5657 . filter ( ( item ) => item . scriptType == 'person_authentication' )
5758 . filter ( ( item ) => item . enabled )
58- . map ( ( item ) => item . name )
59+ . map ( ( item ) => ( { key : item . name , value : item . name } ) )
60+ // Build individual agama flows array
61+ const agamaFlows = buildAgamaFlowsArray ( agamaList )
62+ // Build dropdown options (each flow is a separate entry)
63+ const dropdownOptions = buildDropdownOptions ( filteredScripts , agamaFlows )
5964
60- const agamaFlows = Array . isArray ( agamaList )
61- ? agamaList . map ( ( flow ) => flow ?. details ?. projectMetadata ?. projectName ) . filter ( Boolean )
62- : [ ]
63-
64- filteredScripts . push ( SIMPLE_PASSWORD_AUTH )
65- const result = Array . from ( new Set ( [ ...filteredScripts , ...agamaFlows ] ) ) . sort ( )
66-
67- return result
65+ return dropdownOptions
6866 } , [ scripts , agamaList ] )
6967
7068 const toggle = ( ) => {
@@ -89,12 +87,10 @@ function DefaultAcr() {
8987
9088 if ( put ?. value ) {
9189 const opts = { }
92- opts [ 'authenticationMethod' ] = { defaultAcr : put ? .value }
90+ opts [ 'authenticationMethod' ] = { defaultAcr : put . value }
9391
9492 buildPayload ( userAction , userMessage , opts )
9593 dispatch ( editAcrs ( { data : opts , action : userAction } ) )
96- } else {
97- console . error ( 'No ACR value to save' )
9894 }
9995 }
10096
0 commit comments