Blame view
server/admin/accounts.coffee
1.46 KB
7439c59f5
|
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
### Accounts Server side account creation and manipulation methods. NPM Requires: - Fibers (https://www.npmjs.org/package/fibers) - Futures (https://www.npmjs.org/package/fibers) Configuration: - forbidClientAccountCreation: Disallow client side account creation. Methods: - createUserAccount: Performs a server-side account creation using the Meteor Accounts Password package. ### # NPM Requires Future = Npm.require('fibers/future'); Fibers = Npm.require('fibers'); # Configuration: Accounts.config( forbidClientAccountCreation: true ) # Define Methods Meteor.methods( createUserAccount: (user)-> # Check values against correct pattern. pattern = { email: String, password: String } check(user, pattern) # Define the Future so we can return to the client later. createUserAccount = new Future() # Run the Timeout function and create the user. setTimeout(-> # Run Meteor code in a Fiber. # Note: Accounts.createUser does NOT allow a callback on the server, so we currently # cannot check to see if an error took place. Fibers(-> Accounts.createUser(user) # Send a faux response back to the client. createUserAccount.return({"success": "Account successfully created!"}) ).run() ,300) # Wait for the process to complete. createUserAccount.wait() ) |