fix: Disabling public sharing should disable all existing share links

Issue came through customer support
This commit is contained in:
Tom Moor
2020-11-30 23:39:23 -08:00
parent bde6f4b3c4
commit 1851477290
2 changed files with 28 additions and 1 deletions

View File

@ -4,7 +4,11 @@ import Sequelize from "sequelize";
import { subtractDate } from "../../shared/utils/date";
import documentImporter from "../commands/documentImporter";
import documentMover from "../commands/documentMover";
import { NotFoundError, InvalidRequestError } from "../errors";
import {
NotFoundError,
InvalidRequestError,
AuthorizationError,
} from "../errors";
import auth from "../middlewares/authentication";
import {
Backlink,
@ -17,6 +21,7 @@ import {
Star,
User,
View,
Team,
} from "../models";
import policy from "../policies";
import {
@ -454,6 +459,11 @@ async function loadDocument({ id, shareId, user }) {
if (!share.published) {
authorize(user, "read", document);
}
const team = await Team.findByPk(document.teamId);
if (!team.sharing) {
throw new AuthorizationError();
}
} else {
document = await Document.findByPk(id, {
userId: user ? user.id : undefined,