Commit 0c2fb2c2275d0bab67a1bc288c1c8a5aa4de30df
Exists in
master
Merge branch 'refactor/server_startup_#24'
Showing
4 changed files
Show diff stats
server/admin/browser-policies.js
server/admin/startup-functions/browser-policies.js
server/admin/startup-functions/test-accounts.js
... | ... | @@ -0,0 +1,29 @@ |
1 | +/* | |
2 | +* Generate Test Accounts | |
3 | +* Creates a collection of test accounts automatically on startup. | |
4 | +*/ | |
5 | + | |
6 | +generateTestAccounts = function(){ | |
7 | + // Create an array of user accounts. | |
8 | + var users = [ | |
9 | + { name: "Admin", email: "admin@admin.com", password: "password" } | |
10 | + ] | |
11 | + | |
12 | + // Loop through array of user accounts. | |
13 | + for(i=0; i < users.length; i++){ | |
14 | + // Check if the user already exists in the DB. | |
15 | + var userEmail = users[i].email, | |
16 | + checkUser = Meteor.users.findOne({"emails.address": userEmail}); | |
17 | + | |
18 | + // If an existing user is not found, create the account. | |
19 | + if ( !checkUser ) { | |
20 | + Accounts.createUser({ | |
21 | + email: userEmail, | |
22 | + password: users[i].password, | |
23 | + profile: { | |
24 | + name: users[i].name | |
25 | + } | |
26 | + }); | |
27 | + } | |
28 | + } | |
29 | +} | ... | ... |
server/admin/startup.js
1 | 1 | /* |
2 | 2 | * Startup |
3 | -* Collection of methods and functions to run on server startup. | |
3 | +* Functions to run on server startup. Note: this file is for calling functions | |
4 | +* only. Define functions in /server/admin/startup-functions. | |
4 | 5 | */ |
5 | 6 | |
6 | -/* | |
7 | -* Generate Test Accounts | |
8 | -* Creates a collection of test accounts automatically on startup. | |
9 | -*/ | |
7 | +Meteor.startup(function(){ | |
10 | 8 | |
11 | -// Create an array of user accounts. | |
12 | -var users = [ | |
13 | - { name: "Admin", email: "admin@admin.com", password: "password" } | |
14 | -] | |
9 | + // Custom Browser Policies | |
10 | + customBrowserPolicies(); | |
15 | 11 | |
16 | -// Loop through array of user accounts. | |
17 | -for(i=0; i < users.length; i++){ | |
18 | - // Check if the user already exists in the DB. | |
19 | - var userEmail = users[i].email, | |
20 | - checkUser = Meteor.users.findOne({"emails.address": userEmail}); | |
12 | + // Generate Test Accounts | |
13 | + generateTestAccounts(); | |
21 | 14 | |
22 | - // If an existing user is not found, create the account. | |
23 | - if( !checkUser ){ | |
24 | - Accounts.createUser({ | |
25 | - email: userEmail, | |
26 | - password: users[i].password, | |
27 | - profile: { | |
28 | - name: users[i].name | |
29 | - } | |
30 | - }); | |
31 | - } | |
32 | -} | |
15 | +}); | ... | ... |