Blame view

client/controllers/public/signup.coffee 1.07 KB
d1f4dbea8   Ryan Glover   Additional README...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  ###
      Controller: Signup
      Template: /client/views/public/signup.html
  ###
  
  # Created
  Template.signup.created = ->
      # Code to run when template is created goes here.
  
  # Rendered
  Template.signup.rendered = ->
      # Code to run when template is rendered goes here.
  
  # Helpers
  Template.signup.helpers(
      example: ->
          # Code to run for helper function.
  )
  
  # Events
  Template.signup.events(
7439c59f5   Ryan Glover   Add in a server-o...
22
      'submit form': (e,t) ->
cabe1c46e   Ryan Glover   Add a simple sign...
23
24
25
26
27
28
  
          # Prevent form from submitting.
          e.preventDefault()
  
          # Grab the user's details.
          user =
7439c59f5   Ryan Glover   Add in a server-o...
29
30
              email: t.find('[name="emailAddress"]').value
              password: t.find('[name="password"]').value
cabe1c46e   Ryan Glover   Add a simple sign...
31
32
  
          # Create the user's account.
62a1d9344   Ryan Glover   Refactor server s...
33
          Meteor.call 'createUserAccount', user, (error) ->
7439c59f5   Ryan Glover   Add in a server-o...
34
35
36
  
              # If the account is created successfully, log the user in using the credentials
              # from above.
62a1d9344   Ryan Glover   Refactor server s...
37
38
39
              if error
                  alert error.reason
              else
7439c59f5   Ryan Glover   Add in a server-o...
40
41
42
                  Meteor.loginWithPassword(user.email, user.password, (error)->
                      alert error.reason if error
                  )
d1f4dbea8   Ryan Glover   Additional README...
43
  )