upload files
This commit is contained in:
11
server/routers/back-new/middleware/auth.js
Normal file
11
server/routers/back-new/middleware/auth.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// 简单token认证中间件,支持token-3格式
|
||||
module.exports = function (req, res, next) {
|
||||
const auth = req.headers.authorization;
|
||||
if (auth && auth.startsWith('Bearer token-')) {
|
||||
const id = parseInt(auth.replace('Bearer token-', ''));
|
||||
if (!isNaN(id)) {
|
||||
req.user = { id };
|
||||
}
|
||||
}
|
||||
next();
|
||||
};
|
||||
Reference in New Issue
Block a user