优化vite配置
This commit is contained in:
1 parent
17caf491f1
commit
84025a83ab
5 files changed
+60
-2
No files matched your search
@@ -12,6 +12,7 @@ import { v4 as uuid4 } from "uuid";
|
||||
import jwt from "jsonwebtoken";
|
||||
import sha256 from "crypto-js/sha256.js";
|
||||
import Config from './miaoShareConfig.json' assert { type: 'json' };
|
||||
import { verify } from "crypto";
|
||||
// function loadJSON(path){
|
||||
// return JSON.parse(fs.readFileSync(path).toString());
|
||||
// }
|
||||
@@ -327,13 +328,42 @@ app.post("/user/login", express.json(),function (req, res) {
|
||||
let userGroup = db_getPermissionGroup(id, pwdH);
|
||||
if (userGroup !== null) {
|
||||
res.writeHead(200);
|
||||
let token = jwt.sign({ id, pwd }, JWT_SK, { expiresIn: "168h" });
|
||||
let token = jwt.sign({ id, pwd }, JWT_SK, { expiresIn: `${Config.tokenExpiresIn}h` });
|
||||
res.end(JSON.stringify({ status: "Success", userGroup, token }));
|
||||
} else {
|
||||
res.end(JSON.stringify({ status: "Error" }));
|
||||
}
|
||||
// console.log(req)
|
||||
});
|
||||
|
||||
|
||||
app.post("/user/refrashToken", express.json(),function (req, res) {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Headers", "*");
|
||||
res.header("Access-Control-Allow-Methods", "POST");
|
||||
// console.log(req.body)
|
||||
let { token } = req.body;
|
||||
console.log(req.body)
|
||||
|
||||
let verifyData = jwt.verify(token, JWT_SK);
|
||||
if (verifyData.exp > parseInt(Date.now())) {
|
||||
return res.status(401).json({ message: "Invalid token" });
|
||||
}
|
||||
let id = verifyData.id
|
||||
let pwd = verifyData.pwd
|
||||
let new_token = jwt.sign({ id, pwd }, JWT_SK, { expiresIn: `${Config.tokenExpiresIn}h` });
|
||||
res.end(JSON.stringify({ status: "Success", token }));
|
||||
// let pwdH = sha256(id + pwd).toString();
|
||||
// let userGroup = db_getPermissionGroup(id, pwdH);
|
||||
// if (userGroup !== null) {
|
||||
// res.writeHead(200);
|
||||
// let token = jwt.sign({ id, pwd }, JWT_SK, { expiresIn: `${Config.tokenExpiresIn}h` });
|
||||
// res.end(JSON.stringify({ status: "Success", userGroup, token }));
|
||||
// } else {
|
||||
// res.end(JSON.stringify({ status: "Error" }));
|
||||
// }
|
||||
// console.log(req)
|
||||
});
|
||||
// app.all()
|
||||
app.post("/file/upload", verifyToken, function (req, res) {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
|
||||
Reference in new issue
Block a user