chore: Move to prettier standard double quotes (#1309)
This commit is contained in:
@ -1,89 +1,89 @@
|
||||
// @flow
|
||||
import invariant from 'invariant';
|
||||
import policy from './policy';
|
||||
import { Document, Revision, User } from '../models';
|
||||
import invariant from "invariant";
|
||||
import policy from "./policy";
|
||||
import { Document, Revision, User } from "../models";
|
||||
|
||||
const { allow, cannot } = policy;
|
||||
|
||||
allow(User, 'create', Document);
|
||||
allow(User, "create", Document);
|
||||
|
||||
allow(User, ['read', 'download'], Document, (user, document) => {
|
||||
allow(User, ["read", "download"], Document, (user, document) => {
|
||||
// existance of collection option is not required here to account for share tokens
|
||||
if (document.collection && cannot(user, 'read', document.collection)) {
|
||||
if (document.collection && cannot(user, "read", document.collection)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return user.teamId === document.teamId;
|
||||
});
|
||||
|
||||
allow(User, ['share'], Document, (user, document) => {
|
||||
allow(User, ["share"], Document, (user, document) => {
|
||||
if (document.archivedAt) return false;
|
||||
if (document.deletedAt) return false;
|
||||
|
||||
// existance of collection option is not required here to account for share tokens
|
||||
if (document.collection && cannot(user, 'read', document.collection)) {
|
||||
if (document.collection && cannot(user, "read", document.collection)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return user.teamId === document.teamId;
|
||||
});
|
||||
|
||||
allow(User, ['star', 'unstar'], Document, (user, document) => {
|
||||
allow(User, ["star", "unstar"], Document, (user, document) => {
|
||||
if (document.archivedAt) return false;
|
||||
if (document.deletedAt) return false;
|
||||
if (!document.publishedAt) return false;
|
||||
|
||||
invariant(
|
||||
document.collection,
|
||||
'collection is missing, did you forget to include in the query scope?'
|
||||
"collection is missing, did you forget to include in the query scope?"
|
||||
);
|
||||
if (cannot(user, 'read', document.collection)) return false;
|
||||
if (cannot(user, "read", document.collection)) return false;
|
||||
|
||||
return user.teamId === document.teamId;
|
||||
});
|
||||
|
||||
allow(User, 'update', Document, (user, document) => {
|
||||
allow(User, "update", Document, (user, document) => {
|
||||
if (document.archivedAt) return false;
|
||||
if (document.deletedAt) return false;
|
||||
|
||||
invariant(
|
||||
document.collection,
|
||||
'collection is missing, did you forget to include in the query scope?'
|
||||
"collection is missing, did you forget to include in the query scope?"
|
||||
);
|
||||
if (cannot(user, 'update', document.collection)) return false;
|
||||
if (cannot(user, "update", document.collection)) return false;
|
||||
|
||||
return user.teamId === document.teamId;
|
||||
});
|
||||
|
||||
allow(User, 'createChildDocument', Document, (user, document) => {
|
||||
allow(User, "createChildDocument", Document, (user, document) => {
|
||||
if (document.archivedAt) return false;
|
||||
if (document.archivedAt) return false;
|
||||
if (!document.publishedAt) return false;
|
||||
|
||||
invariant(
|
||||
document.collection,
|
||||
'collection is missing, did you forget to include in the query scope?'
|
||||
"collection is missing, did you forget to include in the query scope?"
|
||||
);
|
||||
if (cannot(user, 'update', document.collection)) return false;
|
||||
if (cannot(user, "update", document.collection)) return false;
|
||||
|
||||
return user.teamId === document.teamId;
|
||||
});
|
||||
|
||||
allow(User, ['move', 'pin', 'unpin'], Document, (user, document) => {
|
||||
allow(User, ["move", "pin", "unpin"], Document, (user, document) => {
|
||||
if (document.archivedAt) return false;
|
||||
if (document.deletedAt) return false;
|
||||
if (!document.publishedAt) return false;
|
||||
|
||||
invariant(
|
||||
document.collection,
|
||||
'collection is missing, did you forget to include in the query scope?'
|
||||
"collection is missing, did you forget to include in the query scope?"
|
||||
);
|
||||
if (cannot(user, 'update', document.collection)) return false;
|
||||
if (cannot(user, "update", document.collection)) return false;
|
||||
|
||||
return user.teamId === document.teamId;
|
||||
});
|
||||
|
||||
allow(User, 'delete', Document, (user, document) => {
|
||||
allow(User, "delete", Document, (user, document) => {
|
||||
// unpublished drafts can always be deleted
|
||||
if (
|
||||
!document.deletedAt &&
|
||||
@ -94,7 +94,7 @@ allow(User, 'delete', Document, (user, document) => {
|
||||
}
|
||||
|
||||
// allow deleting document without a collection
|
||||
if (document.collection && cannot(user, 'update', document.collection)) {
|
||||
if (document.collection && cannot(user, "update", document.collection)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -103,17 +103,17 @@ allow(User, 'delete', Document, (user, document) => {
|
||||
return user.teamId === document.teamId;
|
||||
});
|
||||
|
||||
allow(User, 'restore', Document, (user, document) => {
|
||||
allow(User, "restore", Document, (user, document) => {
|
||||
if (!document.deletedAt) return false;
|
||||
return user.teamId === document.teamId;
|
||||
});
|
||||
|
||||
allow(User, 'archive', Document, (user, document) => {
|
||||
allow(User, "archive", Document, (user, document) => {
|
||||
invariant(
|
||||
document.collection,
|
||||
'collection is missing, did you forget to include in the query scope?'
|
||||
"collection is missing, did you forget to include in the query scope?"
|
||||
);
|
||||
if (cannot(user, 'update', document.collection)) return false;
|
||||
if (cannot(user, "update", document.collection)) return false;
|
||||
|
||||
if (!document.publishedAt) return false;
|
||||
if (document.archivedAt) return false;
|
||||
@ -122,12 +122,12 @@ allow(User, 'archive', Document, (user, document) => {
|
||||
return user.teamId === document.teamId;
|
||||
});
|
||||
|
||||
allow(User, 'unarchive', Document, (user, document) => {
|
||||
allow(User, "unarchive", Document, (user, document) => {
|
||||
invariant(
|
||||
document.collection,
|
||||
'collection is missing, did you forget to include in the query scope?'
|
||||
"collection is missing, did you forget to include in the query scope?"
|
||||
);
|
||||
if (cannot(user, 'update', document.collection)) return false;
|
||||
if (cannot(user, "update", document.collection)) return false;
|
||||
|
||||
if (!document.archivedAt) return false;
|
||||
|
||||
@ -136,7 +136,7 @@ allow(User, 'unarchive', Document, (user, document) => {
|
||||
|
||||
allow(
|
||||
Document,
|
||||
'restore',
|
||||
"restore",
|
||||
Revision,
|
||||
(document, revision) => document.id === revision.documentId
|
||||
);
|
||||
|
Reference in New Issue
Block a user