Blame view

client/modules/signup.js 1.03 KB
db5aba845   Ryan Glover   miscellaneous wor...
1
2
3
  let template;
  
  let _handleSignup = () => {
c39994410   Ryan Glover   wip converting to...
4
5
6
7
    let user = {
      email: template.find( '[name="emailAddress"]' ).value,
      password: template.find( '[name="password"]' ).value
    };
0ccda7775   Ryan Glover   add support for E...
8

c39994410   Ryan Glover   wip converting to...
9
10
11
12
13
14
15
    Accounts.createUser( user, ( error ) => {
      if ( error ) {
        Bert.alert( error.reason, 'danger' );
      } else {
        Bert.alert( 'Welcome!', 'success' );
      }
    });
0ccda7775   Ryan Glover   add support for E...
16
  };
db5aba845   Ryan Glover   miscellaneous wor...
17
  let validation = () => {
0ccda7775   Ryan Glover   add support for E...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    return {
      rules: {
        emailAddress: {
          required: true,
          email: true
        },
        password: {
          required: true,
          minlength: 6
        }
      },
      messages: {
        emailAddress: {
          required: 'Need an email address here.',
          email: 'Is this email address legit?'
        },
        password: {
          required: 'Need a password here.',
          minlength: 'Use at least six characters, please.'
        }
      },
db5aba845   Ryan Glover   miscellaneous wor...
39
      submitHandler() { _handleSignup(); }
0ccda7775   Ryan Glover   add support for E...
40
41
    };
  };
db5aba845   Ryan Glover   miscellaneous wor...
42
43
  let _validate = ( form ) => {
    $( form ).validate( validation() );
0ccda7775   Ryan Glover   add support for E...
44
  };
db5aba845   Ryan Glover   miscellaneous wor...
45
46
47
  export default function( options ) {
    template = options.template;
    _validate( options.form );
c39994410   Ryan Glover   wip converting to...
48
  }