accountSettings.js 745 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. AccountSettings = new Mongo.Collection('accountSettings');
  2. AccountSettings.attachSchema(new SimpleSchema({
  3. _id: {
  4. type: String,
  5. },
  6. booleanValue: {
  7. type: Boolean,
  8. optional: true,
  9. },
  10. sort: {
  11. type: Number,
  12. decimal: true,
  13. },
  14. }));
  15. AccountSettings.allow({
  16. update(userId) {
  17. const user = Users.findOne(userId);
  18. return user && user.isAdmin;
  19. },
  20. });
  21. if (Meteor.isServer) {
  22. Meteor.startup(() => {
  23. AccountSettings.upsert({_id: 'accounts-allowEmailChange'}, {
  24. $setOnInsert: {
  25. booleanValue: false,
  26. sort: 0,
  27. },
  28. });
  29. AccountSettings.upsert({_id: 'accounts-allowUserNameChange'}, {
  30. $setOnInsert: {
  31. booleanValue: false,
  32. sort: 1,
  33. },
  34. });
  35. });
  36. }