Guest User

Untitled

a guest
Nov 24th, 2017
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import { roles } from './../../roles';
  2.  
  3. /**
  4. * User's Information
  5. */
  6. export const users = {
  7. eve: {
  8. uid: null,
  9. email: 'eve@gmail.com',
  10. name: 'eve',
  11. password: 'password',
  12. },
  13. bob: {
  14. uid: null,
  15. email: 'bob@gmail.com',
  16. name: 'eve',
  17. password: 'password',
  18. },
  19. };
  20.  
  21. /**
  22. * Creating bob and eve's user accounts and assigning their userId's to the 'users' object
  23. */
  24. function createUsersAccounts() {
  25. const eveUserId = Accounts.createUser({ email: users.eve.email, password: users.eve.password });
  26. const bobUserId = Accounts.createUser({ email: users.bob.email, password: users.bob.password });
  27.  
  28. users.eve.uid = eveUserId;
  29. users.bob.uid = bobUserId;
  30. }
  31.  
  32. /**
  33. * Creating 'maintainers' role
  34. */
  35. function createMaintainerRole() {
  36. Roles.createRole(roles.maintainers);
  37. }
  38.  
  39. /**
  40. * Creates two users accounts
  41. * 'eve' will have maintainer access
  42. */
  43. export function createMockUsers() {
  44. if (Meteor.isTest) {
  45. // Removing any previous users/roles
  46. Meteor.roles.remove({});
  47. Meteor.users.remove({});
  48.  
  49. createMaintainerRole();
  50.  
  51. createUsersAccounts();
  52.  
  53. Roles.addUsersToRoles(users.eve.uid, roles.maintainers);
  54. }
  55. }
Add Comment
Please, Sign In to add comment