Improved sharing dialog, setting a sheet as public now working
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import '/imports/api/sharing/sharing.js';
|
||||
|
||||
let SharingSchema = new SimpleSchema({
|
||||
owner: {
|
||||
@@ -28,7 +29,7 @@ let SharingSchema = new SimpleSchema({
|
||||
},
|
||||
public: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
defaultValue: false,
|
||||
index: 1,
|
||||
},
|
||||
});
|
||||
|
||||
20
app/imports/api/sharing/sharing.js
Normal file
20
app/imports/api/sharing/sharing.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { assertOwnership } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
||||
import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
|
||||
import { RefSchema } from '/imports/api/parenting/ChildSchema.js';
|
||||
|
||||
const setPublic = new ValidatedMethod({
|
||||
name: 'sharing.methods.setPublic',
|
||||
validate: new SimpleSchema({
|
||||
docRef: RefSchema,
|
||||
public: { type: Boolean },
|
||||
}).validator(),
|
||||
run({docRef, public}){
|
||||
let doc = fetchDocByRef(docRef);
|
||||
assertOwnership(doc, this.userId);
|
||||
getCollectionByName(docRef.collection).update(docRef.id, {$set: {public}});
|
||||
},
|
||||
});
|
||||
|
||||
export { setPublic };
|
||||
@@ -134,8 +134,9 @@ Meteor.users.findUserByUsernameOrEmail = new ValidatedMethod({
|
||||
},
|
||||
}).validator(),
|
||||
run({usernameOrEmail}){
|
||||
let user = Accounts.findUserByUsername(username) ||
|
||||
Accounts.findUserByEmail(email);
|
||||
if (Meteor.isClient) return;
|
||||
let user = Accounts.findUserByUsername(usernameOrEmail) ||
|
||||
Accounts.findUserByEmail(usernameOrEmail);
|
||||
return user && user._id;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user