@@ -188,23 +188,20 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
188188
189189 routes . post ( '/featureService/validate' , async ( req , res ) => {
190190 const config = await processor . safeGetConfig ( )
191- const { url, auth = { } } = req . body
192- const { token, username, password } = auth
191+ const { url, token, username, password } = req . body
193192 if ( ! URL . canParse ( url ) ) {
194193 return res . send ( 'Invalid feature service url' ) . status ( 400 )
195194 }
196195
197196 let service : FeatureServiceConfig
198197 let identityManager : ArcGISIdentityManager
199198 if ( token ) {
200- identityManager = await ArcGISIdentityManager . fromToken ( {
201- token : token
202- } )
199+ identityManager = await ArcGISIdentityManager . fromToken ( { token } )
203200 service = { url, layers : [ ] , identityManager : identityManager . serialize ( ) }
204201 } else if ( username && password ) {
205202 identityManager = await ArcGISIdentityManager . signIn ( {
206- username : auth ?. username ,
207- password : auth ?. password ,
203+ username,
204+ password,
208205 portal : getPortalUrl ( url )
209206 } )
210207 service = { url, layers : [ ] , identityManager : identityManager . serialize ( ) }
@@ -220,7 +217,8 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
220217 }
221218
222219 await processor . patchConfig ( config )
223- return res . send ( sanitizeFeatureService ( service , identityService ) )
220+ const sanitized = await sanitizeFeatureService ( service , identityService )
221+ return res . send ( sanitized )
224222 } catch ( err ) {
225223 return res . send ( 'Invalid credentials provided to communicate with feature service' ) . status ( 400 )
226224 }
0 commit comments