Blame view

server/admin/startup-functions/test-accounts.js 758 Bytes
c2a6cf38e   Ryan Glover   Refactor /server/...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  /*
  * Generate Test Accounts
  * Creates a collection of test accounts automatically on startup.
  */
  
  generateTestAccounts = function(){
    // Create an array of user accounts.
    var users = [
      { name: "Admin", email: "admin@admin.com", password: "password" }
    ]
  
    // Loop through array of user accounts.
    for(i=0; i < users.length; i++){
      // Check if the user already exists in the DB.
      var userEmail = users[i].email,
          checkUser = Meteor.users.findOne({"emails.address": userEmail});
  
      // If an existing user is not found, create the account.
      if ( !checkUser ) {
        Accounts.createUser({
          email: userEmail,
          password: users[i].password,
          profile: {
            name: users[i].name
          }
        });
      }
    }
  }