Blame view

client/modules/login.js 984 Bytes
db5aba845   Ryan Glover   miscellaneous wor...
1
2
3
  let template;
  
  let _handleLogin = () => {
c39994410   Ryan Glover   wip converting to...
4
5
    let email    = template.find( '[name="emailAddress"]' ).value,
        password = template.find( '[name="password"]' ).value;
0ccda7775   Ryan Glover   add support for E...
6

c39994410   Ryan Glover   wip converting to...
7
8
9
10
11
12
13
    Meteor.loginWithPassword( email, password, ( error ) => {
      if ( error ) {
        Bert.alert( error.reason, 'warning' );
      } else {
        Bert.alert( 'Logged in!', 'success' );
      }
    });
0ccda7775   Ryan Glover   add support for E...
14
  };
db5aba845   Ryan Glover   miscellaneous wor...
15
  let validation = () => {
0ccda7775   Ryan Glover   add support for E...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
    return {
      rules: {
        emailAddress: {
          required: true,
          email: true
        },
        password: {
          required: true
        }
      },
      messages: {
        emailAddress: {
          required: 'Need an email address here.',
          email: 'Is this email address legit?'
        },
        password: {
          required: 'Need a password here.'
        }
      },
db5aba845   Ryan Glover   miscellaneous wor...
35
      submitHandler() { _handleLogin(); }
0ccda7775   Ryan Glover   add support for E...
36
37
    };
  };
db5aba845   Ryan Glover   miscellaneous wor...
38
39
  let _validate = ( form ) => {
    $( form ).validate( validation() );
0ccda7775   Ryan Glover   add support for E...
40
  };
db5aba845   Ryan Glover   miscellaneous wor...
41
42
43
  export default function( options ) {
    template = options.template;
    _validate( options.form );
c39994410   Ryan Glover   wip converting to...
44
  }