@zhongqian97-code/ecode 0.5.17 → 0.5.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5234,12 +5234,13 @@ function generateAccessToken() {
|
|
|
5234
5234
|
}
|
|
5235
5235
|
function createAuthHook(token) {
|
|
5236
5236
|
return function authHook(request, reply, done) {
|
|
5237
|
-
const
|
|
5238
|
-
|
|
5239
|
-
|
|
5237
|
+
const headerToken = request.headers["x-ecode-token"];
|
|
5238
|
+
const queryToken = request.query?.["token"];
|
|
5239
|
+
if (headerToken === token || queryToken === token) {
|
|
5240
|
+
done();
|
|
5240
5241
|
return;
|
|
5241
5242
|
}
|
|
5242
|
-
|
|
5243
|
+
reply.code(401).send({ success: false, error: "Unauthorized" });
|
|
5243
5244
|
};
|
|
5244
5245
|
}
|
|
5245
5246
|
|
|
@@ -6101,11 +6102,12 @@ if (rawArgs[0] === "web") {
|
|
|
6101
6102
|
version: VERSION
|
|
6102
6103
|
});
|
|
6103
6104
|
await server.listen({ port: webPort, host: webHost });
|
|
6104
|
-
const
|
|
6105
|
+
const browserHost = webHost === "0.0.0.0" ? "localhost" : webHost;
|
|
6106
|
+
const accessUrl = `http://${browserHost}:${webPort}?token=${token}`;
|
|
6105
6107
|
console.log(`
|
|
6106
6108
|
ecode web admin started`);
|
|
6107
|
-
console.log(`
|
|
6108
|
-
console.log(`
|
|
6109
|
+
console.log(` Bind: ${webHost}:${webPort}`);
|
|
6110
|
+
console.log(` URL: ${accessUrl}`);
|
|
6109
6111
|
console.log(`
|
|
6110
6112
|
Press Ctrl+C to stop.
|
|
6111
6113
|
`);
|