Skip to content

Commit a4918dc

Browse files
committed
Make middleware to throw forbidden error
1 parent 325f1b5 commit a4918dc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app/manage/permissions/clients.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ const db = require('../../db')
1111
* @returns {boolean} can the request go through?
1212
*/
1313
async function clients (uid) {
14-
let conn = await db()
15-
const [user] = await conn('users').where('id', uid)
16-
if (user) {
17-
return true
14+
try {
15+
let conn = await db()
16+
const [user] = await conn('users').where('id', uid)
17+
if (user) {
18+
return true
19+
}
20+
} catch (error) {
21+
throw Error('Forbidden')
1822
}
1923
}
2024

0 commit comments

Comments
 (0)