Return scoped carriers and speech creds in /SP GET call (#96)

* return scoped carriers and speech creds in /SP GET call

* apply review comments

Co-authored-by: eglehelms <e.helms@cognigy.com>
This commit is contained in:
EgleHandeglehelms authored and GitHub committed 2023-01-19 10:53:37 -05:00
1 parent 274377960e
commit 80ee1d06d7
2 files changed
+12 -3

No files matched your search

+5 -1
View File
@@ -151,10 +151,14 @@ router.get('/', async(req, res) => {
if (!account_sid) service_provider_sid = parseServiceProviderSid(req);
const logger = req.app.locals.logger;
try {
const creds = account_sid ?
let creds = account_sid ?
await SpeechCredential.retrieveAll(account_sid) :
await SpeechCredential.retrieveAllForSP(service_provider_sid);
if (req.user.hasScope('account')) {
creds = creds.filter((c) => c.account_sid === req.user.account_sid || !c.account_sid);
}
res.status(200).json(creds.map((c) => {
const {credential, ...obj} = c;
if ('google' === obj.vendor) {