Blame view
client/modules/login.js
984 Bytes
db5aba845
|
1 2 3 |
let template; let _handleLogin = () => { |
c39994410
|
4 5 |
let email = template.find( '[name="emailAddress"]' ).value, password = template.find( '[name="password"]' ).value; |
0ccda7775
|
6 |
|
c39994410
|
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
|
14 |
}; |
db5aba845
|
15 |
let validation = () => { |
0ccda7775
|
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
|
35 |
submitHandler() { _handleLogin(); } |
0ccda7775
|
36 37 |
}; }; |
db5aba845
|
38 39 |
let _validate = ( form ) => { $( form ).validate( validation() ); |
0ccda7775
|
40 |
}; |
db5aba845
|
41 42 43 |
export default function( options ) { template = options.template; _validate( options.form ); |
c39994410
|
44 |
} |