Commit 39d39619c844cda413bb1c8d42411ee7c5bf5443

Authored by Ryan Glover
1 parent 5f6f6fbb0b
Exists in master

Add automatic account creation to server startup. Update documentation with latest changes.

Showing 2 changed files with 49 additions and 9 deletions   Show diff stats
... ... @@ -41,16 +41,16 @@ Base comes with a pre-defined file structure common to all projects along with s
41 41 ---------routes-public.coffee
42 42 ------/stylesheets
43 43 ---------/globals
  44 +------------_extends.scss
44 45 ---------/modules
45 46 ---------/vendor
46 47 ---------/views
47 48 ------------/public
48 49 ---------------_login.scss
49   ----------------_recover-password.scss
50   ----------------_reset-password.scss
51   ----------------_signup.scss
52 50 ---------app.scss
53 51 -------/views
  52 +---------/authenticated
  53 +------------index.html
54 54 ---------/public
55 55 ------------login.html
56 56 ------------recover-password.html
... ... @@ -60,18 +60,16 @@ Base comes with a pre-defined file structure common to all projects along with s
60 60 ------example.coffee
61 61 ---/lib
62 62 ---/packages
  63 +------ (See List Above)
63 64 ---/public
64 65 ---/server
65 66 ------/admin
66 67 ---------accounts.coffee
67 68 ---------startup.coffee
68 69 ------/publications
69   ----------example.coffee
70 70 ------/email
71 71 ---------/send
72   -------------example.coffee
73 72 ---------/templates
74   -------------example.handlebars
75 73 ------/data
76 74 ---------/insert
77 75 ---------/update
... ... @@ -83,8 +81,21 @@ There are two considerations when using Base: JavaScript is written in [CoffeeSc
83 81  
84 82 ### Functionality
85 83  
86   -###### Basic Routing (Not Included Yet, Just Documenting)
87   -A collection of pre-defined routes and templates for common functionality (see Authenticate below). Also includes a set of common route filters for managing user access.
  84 +###### Basic Routing
  85 +A collection of pre-defined routes and templates for common functionality (see Authenticate below). Also includes a set of common route filters for managing user access. Routes bundled include:
  86 +
  87 +```
  88 +- / (Authenticated)
  89 +- /login (Public)
  90 +- /signup (Public)
  91 +- /recover-password (Public)
  92 +- /reset-password (Public)
  93 +```
88 94  
89 95 ###### Authentication (Not Included Yet, Just Documenting)
90   -A complete authentication pattern complete with: signup, login, and password recovery. Also includes an automated user creation script in `/server/startup.coffee`.
  96 +A complete authentication pattern complete with: signup, login, and password recovery. Feautres:
  97 +
  98 +- Server-only Account Creation (to prevent client-side signups)
  99 +
  100 +###### Automatic Admin User Creation
  101 +When developing, having a handful of user accounts to test your application with can come in handy. Base comes with an automated account generation script located in `server/admin/startup.coffee` that creates accounts based on an array of specified users. **Note**: by default this creates one Admin user on server startup, so make sure to customize or remove this user so the public can't access your app :)
... ...
server/admin/startup.coffee
... ... @@ -0,0 +1,29 @@
  1 +###
  2 + Startup
  3 + Collection of methods and functions to run on server startup.
  4 +###
  5 +
  6 +# Generate Test Accounts
  7 +# Creates a collection of test accounts automatically on startup.
  8 +
  9 +# Create an array of user accounts.
  10 +users = [
  11 + { name: "Admin", email: "admin@admin.com", password: "password" }
  12 +]
  13 +
  14 +# Loop through array of user accounts.
  15 +for user in users
  16 +
  17 + # Check if the user already exists in the DB.
  18 + checkUser = Meteor.users.findOne({"emails.address": user.email});
  19 +
  20 + # If an existing user is not found, create the account.
  21 + if not checkUser
  22 +
  23 + id = Accounts.createUser(
  24 + email: user.email
  25 + password: user.password
  26 + profile:
  27 + name: user.name
  28 + )
  29 +
... ...