server.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // start up script that creates some users for testing
  2. // users have the username 'user1@test.com' .. 'user8@test.com'
  3. // and the password test123
  4. Meteor.startup(function () {
  5. if (!Meteor.users.findOne()) {
  6. for (let i = 1; i < 9; i++) {
  7. let email = "user" + i + "@test.com";
  8. let username = "user" + i;
  9. let avatar = "ava" + i + ".png";
  10. console.log("creating a user with password 'test123' and username/ email: " + email);
  11. Meteor.users.insert({
  12. profile: {
  13. username: username,
  14. avatar: avatar
  15. },
  16. emails: [{ address: email }],
  17. services: { password: { "bcrypt": "$2a$10$I3erQ084OiyILTv8ybtQ4ON6wusgPbMZ6.P33zzSDei.BbDL.Q4EO" } }
  18. });
  19. }
  20. }
  21. Meteor.publish("chats", function () {
  22. Meteor._debug("publishing chats. User", this.userId);
  23. let myId = this.userId || "anon";
  24. const selector = {
  25. $or: [
  26. { user1Id: myId },
  27. { user2Id: myId }
  28. ]
  29. };
  30. return Chats.find(selector);
  31. });
  32. Meteor.publish("users", function () {
  33. return Meteor.users.find();
  34. });
  35. });