Blame view
client/modules/login.js
1.01 KB
0ccda7775
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
let login = ( options ) => { _validate( options.form, options.template ); }; let _validate = ( form, template ) => { $( form ).validate( validation( template ) ); }; let validation = ( template ) => { 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.' } }, submitHandler() { _handleLogin( template ); } }; }; let _handleLogin = ( template ) => { let email = template.find( '[name="emailAddress"]' ).value, password = template.find( '[name="password"]' ).value; Meteor.loginWithPassword( email, password, ( error ) => { if ( error ) { Bert.alert( error.reason, 'warning' ); } else { Bert.alert( 'Logged in!', 'success' ); } }); }; Modules.client.login = login; |