microgen-cli
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -92,4 +92,3 @@ const cote = require("microgen-cote"); | ||
const verify = await app.getRequester('user').send({ type: 'verifyToken', token }) | ||
const access = typeof authentication == "string" ? verify.user.role == authentication : authentication.includes(verify.user.role); | ||
if(verify.user.role != "admin" && !access) { | ||
if(!verify.user) { | ||
throw new Error("UnAuthorized") | ||
@@ -111,6 +110,17 @@ } else { | ||
if(request.isPublic && connection && connection == "private") { | ||
callback({ | ||
statusCode: 403, | ||
message: "Access is forbidden" | ||
}, null); | ||
const token = request.headers.authorization; | ||
if(token) { | ||
const verify = await app.getRequester('user').send({ type: 'verifyToken', token }) | ||
if(verify.user.role != "admin") { | ||
callback({ | ||
statusCode: 403, | ||
message: "Access is forbidden" | ||
}, null); | ||
} | ||
} else { | ||
callback({ | ||
statusCode: 403, | ||
message: "Access is forbidden" | ||
}, null); | ||
} | ||
} | ||
@@ -117,0 +127,0 @@ delete request.isPublic; |
{ | ||
"name": "microgen-cli", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./bin/index.js", |
9130
301