microgen-client
Advanced tools
Comparing version 0.0.3 to 0.0.4
21
index.js
@@ -44,3 +44,3 @@ const http = require('http'); | ||
if(response.status == 'success') { | ||
resolve(data); | ||
resolve(response); | ||
} else { | ||
@@ -58,10 +58,21 @@ reject("failed"); | ||
const middleware = ({ app, clientId }) => (req, res, next) => { | ||
if(!app.get("microgen") && clientId) { | ||
if(app.get("microgen") == "unauthorized") { | ||
res.send({ message: "invalid hostname" }) | ||
} | ||
if((app.get("microgen") !== "authorized") && clientId) { | ||
client(clientId) | ||
.then(res => { | ||
console.log(res) | ||
console.log(req.hostname) | ||
if(req.hostname.includes(res.hostname)) { | ||
app.set("microgen", "authorized") | ||
return; | ||
} else { | ||
app.set("microgen", "unauthorized") | ||
res.send({ message: "invalid hostname" }) | ||
return; | ||
} | ||
}) | ||
.catch(err => { | ||
console.log(err); | ||
app.set("microgen", "unauthorized") | ||
res.send({ message: "invalid hostname" }) | ||
return; | ||
}) | ||
@@ -68,0 +79,0 @@ } else { |
{ | ||
"name": "microgen-client", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2295
75