Commit 62a1d9344abbcd0f14447439a3cc92b6236b2030
1 parent
7439c59f5f
Exists in
master
Refactor server side component for sign up flow to remove need for Futures/Fibers.
Showing
2 changed files
with
6 additions
and
29 deletions
Show diff stats
client/controllers/public/signup.coffee
... | ... | @@ -30,11 +30,13 @@ Template.signup.events( |
30 | 30 | password: t.find('[name="password"]').value |
31 | 31 | |
32 | 32 | # Create the user's account. |
33 | - Meteor.call 'createUserAccount', user, (error,response) -> | |
33 | + Meteor.call 'createUserAccount', user, (error) -> | |
34 | 34 | |
35 | 35 | # If the account is created successfully, log the user in using the credentials |
36 | 36 | # from above. |
37 | - if response.success | |
37 | + if error | |
38 | + alert error.reason | |
39 | + else | |
38 | 40 | Meteor.loginWithPassword(user.email, user.password, (error)-> |
39 | 41 | alert error.reason if error |
40 | 42 | ) | ... | ... |
server/admin/accounts.coffee
... | ... | @@ -2,10 +2,6 @@ |
2 | 2 | Accounts |
3 | 3 | Server side account creation and manipulation methods. |
4 | 4 | |
5 | - NPM Requires: | |
6 | - - Fibers (https://www.npmjs.org/package/fibers) | |
7 | - - Futures (https://www.npmjs.org/package/fibers) | |
8 | - | |
9 | 5 | Configuration: |
10 | 6 | - forbidClientAccountCreation: Disallow client side account creation. |
11 | 7 | |
... | ... | @@ -13,10 +9,6 @@ |
13 | 9 | - createUserAccount: Performs a server-side account creation using the Meteor Accounts Password package. |
14 | 10 | ### |
15 | 11 | |
16 | -# NPM Requires | |
17 | -Future = Npm.require('fibers/future'); | |
18 | -Fibers = Npm.require('fibers'); | |
19 | - | |
20 | 12 | # Configuration: |
21 | 13 | Accounts.config( |
22 | 14 | forbidClientAccountCreation: true |
... | ... | @@ -31,23 +23,6 @@ Meteor.methods( |
31 | 23 | pattern = { email: String, password: String } |
32 | 24 | check(user, pattern) |
33 | 25 | |
34 | - # Define the Future so we can return to the client later. | |
35 | - createUserAccount = new Future() | |
36 | - | |
37 | - # Run the Timeout function and create the user. | |
38 | - setTimeout(-> | |
39 | - | |
40 | - # Run Meteor code in a Fiber. | |
41 | - # Note: Accounts.createUser does NOT allow a callback on the server, so we currently | |
42 | - # cannot check to see if an error took place. | |
43 | - Fibers(-> | |
44 | - Accounts.createUser(user) | |
45 | - # Send a faux response back to the client. | |
46 | - createUserAccount.return({"success": "Account successfully created!"}) | |
47 | - ).run() | |
48 | - | |
49 | - ,300) | |
50 | - | |
51 | - # Wait for the process to complete. | |
52 | - createUserAccount.wait() | |
26 | + # Create the user. | |
27 | + Accounts.createUser(user) | |
53 | 28 | ) | ... | ... |