user-manager change
This commit is contained in:
@@ -91,6 +91,7 @@ app
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const id = ctx.query.id;
|
||||
const deleteFile = !!ctx.query.deleteFile; // 是否删除文件, 默认不删除
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
}
|
||||
@@ -106,7 +107,7 @@ app
|
||||
throw new CustomError('app is published');
|
||||
}
|
||||
const files = app.data.files || [];
|
||||
if (files.length > 0) {
|
||||
if (deleteFile && files.length > 0) {
|
||||
await deleteFiles(files.map((item) => item.path));
|
||||
}
|
||||
await app.destroy({
|
||||
@@ -217,13 +218,25 @@ app
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const { id, username } = ctx.query.data;
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
const { id, username, appKey, version } = ctx.query.data;
|
||||
if (!id && !appKey) {
|
||||
throw new CustomError('id or appKey is required');
|
||||
}
|
||||
|
||||
const uid = await getUidByUsername(app, ctx, username);
|
||||
const appList = await AppListModel.findByPk(id);
|
||||
let appList: AppListModel | null = null;
|
||||
if (id) {
|
||||
appList = await AppListModel.findByPk(id);
|
||||
if (appList?.uid !== uid) {
|
||||
throw new CustomError('no permission');
|
||||
}
|
||||
}
|
||||
if (!appList && appKey) {
|
||||
if (!version) {
|
||||
throw new CustomError('version is required');
|
||||
}
|
||||
appList = await AppListModel.findOne({ where: { key: appKey, version, uid } });
|
||||
}
|
||||
if (!appList) {
|
||||
throw new CustomError('app not found');
|
||||
}
|
||||
@@ -265,7 +278,6 @@ app
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
|
||||
app
|
||||
.route({
|
||||
path: 'app',
|
||||
|
||||
Reference in New Issue
Block a user