mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 03:19:02 +08:00
feat(wip): 支持 JWT
This commit is contained in:
parent
542957d34a
commit
2320ab3838
@ -30,15 +30,27 @@ export default function register($app) {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const { payload, options } = req.body;
|
try {
|
||||||
const jwt = eval(`require("jsonwebtoken")`);
|
const { payload, options } = req.body;
|
||||||
res.set('Content-Type', 'application/json;charset=utf-8').send({
|
const jwt = eval(`require("jsonwebtoken")`);
|
||||||
token: jwt.sign(
|
const token = jwt.sign(
|
||||||
payload,
|
payload,
|
||||||
eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH'),
|
eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH'),
|
||||||
options,
|
options,
|
||||||
),
|
);
|
||||||
});
|
res.set('Content-Type', 'application/json;charset=utf-8').send({
|
||||||
|
token,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
return failed(
|
||||||
|
res,
|
||||||
|
new InternalServerError(
|
||||||
|
'JWT_SIGN_FAILED',
|
||||||
|
`Failed to sign JWT token`,
|
||||||
|
`Reason: ${e.message ?? e}`,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Storage management
|
// Storage management
|
||||||
|
@ -24,6 +24,7 @@ if (isLanceX) backend = 'LanceX';
|
|||||||
if (isGUIforCores) backend = 'GUI.for.Cores';
|
if (isGUIforCores) backend = 'GUI.for.Cores';
|
||||||
|
|
||||||
let meta = {};
|
let meta = {};
|
||||||
|
let feature = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (typeof $environment !== 'undefined') {
|
if (typeof $environment !== 'undefined') {
|
||||||
@ -43,6 +44,12 @@ try {
|
|||||||
meta.plugin = $Plugin;
|
meta.plugin = $Plugin;
|
||||||
}
|
}
|
||||||
if (isNode) {
|
if (isNode) {
|
||||||
|
if (
|
||||||
|
eval('process.env.SUB_STORE_FRONTEND_BACKEND_PATH') &&
|
||||||
|
eval('process.env.SUB_STORE_FRONTEND_PATH')
|
||||||
|
) {
|
||||||
|
feature.share = true;
|
||||||
|
}
|
||||||
meta.node = {
|
meta.node = {
|
||||||
version: eval('process.version'),
|
version: eval('process.version'),
|
||||||
argv: eval('process.argv'),
|
argv: eval('process.argv'),
|
||||||
@ -63,5 +70,6 @@ try {
|
|||||||
export default {
|
export default {
|
||||||
backend,
|
backend,
|
||||||
version: substoreVersion,
|
version: substoreVersion,
|
||||||
|
feature,
|
||||||
meta,
|
meta,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user