Commit 84e777fe authored by anton's avatar anton

Add find action to manage service, add ADMIN_CONNECTION

parent 46a5a9c6
Pipeline #53008 failed
......@@ -61,7 +61,8 @@
"tokenEndpoint": "ADMIN_TOKEN_ENDPOINT",
"clientId": "ADMIN_CLIENT_ID",
"clientSecret": "ADMIN_CLIENT_SECRET",
"audience": "ADMIN_AUDIENCE"
"audience": "ADMIN_AUDIENCE",
"connection": "ADMIN_CONNECTION"
}
},
"microservices": {
......
......@@ -68,7 +68,8 @@
"tokenEndpoint": null,
"clientId": null,
"clientSecret": null,
"audience": null
"audience": null,
"connection": null
}
},
"apiKeys": {
......
......@@ -56,6 +56,35 @@ class Manage extends TinyEmitter {
return Array.isArray(req.user.profile.roles) && req.user.profile.roles.indexOf('admin') > -1
}
api.app.get('/manage', async (req, res) => {
if (!req.user || !isAdmin(req)) {
return send(res, 403)
}
const headers = await getHeaders()
try {
let pagination = {}
const filter = req.query.filter
if (req.query.pagination) pagination = JSON.parse(req.query.pagination)
const query = {
page: pagination.page ? pagination.page - 1 : 0,
per_page: pagination.rowsPerPage || 10,
include_totals: true,
search_engine: 'v3',
q: filter ? `identities.connection:"${_config.connection}" AND email:${filter}*` : undefined,
sort: `${pagination.sortBy || 'email'}:${pagination.descending ? -1 : 1}`
}
const result = await axios.get(`${_config.apiEndpoint}users`, { headers, params: query })
send(res, 200, result.data)
}
catch (err) {
if (err.response) send(res, err.response.status)
else {
console.error(`GET /manage`, err.message)
}
}
})
api.app.get('/manage/:id', async (req, res) => {
if (!req.user || (!isAdmin(req) && req.params.id !== req.user.id)) {
return send(res, 403)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment