feat: some add auth
This commit is contained in:
@@ -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;
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user