mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-11-21 03:12:10 +08:00
feat(panel): api-key
新增请求头[x-request-api-key] 将apikey放入该请求头中,兼容旧apikey方式
This commit is contained in:
parent
07cde2f488
commit
7a5c366811
@ -66,8 +66,13 @@ export default (parameter: IPermissionCfg) => {
|
||||
}
|
||||
|
||||
// If it is an API request, perform API-level permission judgment
|
||||
if (ctx.query.apikey) {
|
||||
const apiKey = String(ctx.query.apikey);
|
||||
/**
|
||||
* @date update time: 2024-08-06
|
||||
* @description Added a new "API-KEY" filling method
|
||||
*/
|
||||
const key = ctx.request?.header["x-request-api-key"] || ctx.query.apikey;
|
||||
if (key) {
|
||||
const apiKey = String(key);
|
||||
const user = getUuidByApiKey(apiKey);
|
||||
if (user && user.permission >= Number(parameter.level)) {
|
||||
return await next();
|
||||
|
Loading…
Reference in New Issue
Block a user