Skip to content

Commit

Permalink
Merge pull request #27 from developmentseed/assign-client-owner
Browse files Browse the repository at this point in the history
set owner when creating a client
  • Loading branch information
sethvincent authored Jul 8, 2019
2 parents 2c4ad48 + 0b27df0 commit 381dee5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/manage/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ const manageId = serverRuntimeConfig.OSM_HYDRA_ID
* @param {*} res
*/
async function getClients (req, res) {
const { session: { user_id } } = req
let clients = await hydra.getClients()

// Remove first party app from list
let filteredClients = clients.filter(c => c.client_id !== manageId)
// Remove first party client from list & exclude clients the user does not own
let filteredClients = clients
.filter(c => c.client_id !== manageId && c.owner === user_id)

return res.send({ clients: filteredClients })
}
Expand All @@ -31,6 +33,7 @@ async function createClient (req, res) {
toCreate['scope'] = 'openid offline'
toCreate['response_types'] = ['code', 'id_token']
toCreate['grant_types'] = ['refresh_token', 'authorization_code']
toCreate['owner'] = req.session.user_id
let client = await hydra.createClient(toCreate)
return res.send({ client })
}
Expand Down

0 comments on commit 381dee5

Please sign in to comment.