-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: topics/k1ch/ introduce get/personas-permissions
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const createError = require('http-errors') | ||
const dbAdminPersona = require('database/layer/admin-persona') | ||
const { checkPersonaExists } = require('./utils') | ||
|
||
const getPersonaPermissions = async (req, res, next) => { | ||
try { | ||
const { persona_key: personaKey } = req.params | ||
await checkPersonaExists(personaKey) | ||
const permissions = await dbAdminPersona.getPersonaPermissions(personaKey) | ||
res.status(200).send(permissions) | ||
} catch ({ httpStatusCode = 500, message }) { | ||
return next(createError(httpStatusCode, { message })) | ||
} | ||
} | ||
|
||
module.exports = { | ||
getPersonaPermissions, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const dbAdminPersona = require('database/layer/admin-persona') | ||
|
||
const checkPersonaExists = async (personaKey) => { | ||
const persona = await dbAdminPersona.getPersona(personaKey) | ||
if (!persona) { | ||
throw { | ||
httpStatusCode: 404, | ||
message: 'Persona does not exist!' | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
checkPersonaExists, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters