Skip to content

Commit

Permalink
[service] fix regression in token, username/password validation req p…
Browse files Browse the repository at this point in the history
…arameter parsing
  • Loading branch information
newmanw committed Nov 13, 2024
1 parent f7cb430 commit c9fe35e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions plugins/arcgis/service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,20 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {

routes.post('/featureService/validate', async (req, res) => {
const config = await processor.safeGetConfig()
const { url, auth = {} } = req.body
const { token, username, password } = auth
const { url, token, username, password } = req.body
if (!URL.canParse(url)) {
return res.send('Invalid feature service url').status(400)
}

let service: FeatureServiceConfig
let identityManager: ArcGISIdentityManager
if (token) {
identityManager = await ArcGISIdentityManager.fromToken({
token: token
})
identityManager = await ArcGISIdentityManager.fromToken({ token })
service = { url, layers: [], identityManager: identityManager.serialize() }
} else if (username && password) {
identityManager = await ArcGISIdentityManager.signIn({
username: auth?.username,
password: auth?.password,
username,
password,
portal: getPortalUrl(url)
})
service = { url, layers: [], identityManager: identityManager.serialize() }
Expand All @@ -220,7 +217,8 @@ const arcgisPluginHooks: InitPluginHook<typeof InjectedServices> = {
}

await processor.patchConfig(config)
return res.send(sanitizeFeatureService(service, identityService))
const sanitized = await sanitizeFeatureService(service, identityService)
return res.send(sanitized)
} catch (err) {
return res.send('Invalid credentials provided to communicate with feature service').status(400)
}
Expand Down

0 comments on commit c9fe35e

Please sign in to comment.