feat: some add auth

This commit is contained in:
2024-10-02 00:22:54 +08:00
parent 6f0535e2ef
commit 8436b0462a
12 changed files with 203 additions and 2 deletions

View File

@@ -47,9 +47,11 @@ app
.route({
path: 'page',
key: 'update',
middleware: ['auth'],
})
.define(async (ctx) => {
const { data, id, title, type, description } = ctx.query.data;
const tokenUser = ctx.state.tokenUser;
if (id) {
const page = await PageModel.findByPk(id);
if (page) {
@@ -59,7 +61,7 @@ app
throw new CustomError('page not found');
}
} else if (data) {
const page = await PageModel.create({ data, title, type, description });
const page = await PageModel.create({ data, title, type, description, uid: tokenUser.id });
ctx.body = page;
}
})