New database with migrations
This commit is contained in:
@ -23,8 +23,8 @@ router.post('documents.info', auth({ require: false }), async (ctx) => {
|
||||
if (document.private) {
|
||||
if (!ctx.state.user) throw httpErrors.NotFound();
|
||||
|
||||
const team = await ctx.state.user.getTeam();
|
||||
if (document.teamId !== team.id) {
|
||||
const user = await ctx.state.user;
|
||||
if (document.teamId !== user.teamId) {
|
||||
throw httpErrors.NotFound();
|
||||
}
|
||||
|
||||
@ -52,11 +52,10 @@ router.post('documents.create', auth(), async (ctx) => {
|
||||
ctx.assertPresent(text, 'text is required');
|
||||
|
||||
const user = ctx.state.user;
|
||||
const team = await user.getTeam();
|
||||
const ownerAtlas = await Atlas.findOne({
|
||||
where: {
|
||||
id: atlas,
|
||||
teamId: team.id,
|
||||
teamId: user.teamId,
|
||||
},
|
||||
});
|
||||
|
||||
@ -64,7 +63,7 @@ router.post('documents.create', auth(), async (ctx) => {
|
||||
|
||||
const document = await Document.create({
|
||||
atlasId: ownerAtlas.id,
|
||||
teamId: team.id,
|
||||
teamId: user.teamId,
|
||||
userId: user.id,
|
||||
title: title,
|
||||
text: text,
|
||||
@ -86,11 +85,10 @@ router.post('documents.update', auth(), async (ctx) => {
|
||||
ctx.assertPresent(text, 'text is required');
|
||||
|
||||
const user = ctx.state.user;
|
||||
const team = await user.getTeam();
|
||||
let document = await Document.findOne({
|
||||
where: {
|
||||
id: id,
|
||||
teamId: team.id,
|
||||
teamId: user.teamId,
|
||||
},
|
||||
});
|
||||
|
||||
@ -112,11 +110,10 @@ router.post('documents.delete', auth(), async (ctx) => {
|
||||
ctx.assertPresent(id, 'id is required');
|
||||
|
||||
const user = ctx.state.user;
|
||||
const team = await user.getTeam();
|
||||
let document = await Document.findOne({
|
||||
where: {
|
||||
id: id,
|
||||
teamId: team.id,
|
||||
teamId: user.teamId,
|
||||
},
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user