Blame view
client/modules/signup.js
1.05 KB
c39994410
|
1 2 3 4 5 |
let _handleSignup = ( template ) => { let user = { email: template.find( '[name="emailAddress"]' ).value, password: template.find( '[name="password"]' ).value }; |
0ccda7775
|
6 |
|
c39994410
|
7 8 9 10 11 12 13 |
Accounts.createUser( user, ( error ) => { if ( error ) { Bert.alert( error.reason, 'danger' ); } else { Bert.alert( 'Welcome!', 'success' ); } }); |
0ccda7775
|
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 |
}; let validation = ( template ) => { 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.' } }, submitHandler() { _handleSignup( template ); } }; }; |
c39994410
|
41 42 |
let _validate = ( form, template ) => { $( form ).validate( validation( template ) ); |
0ccda7775
|
43 |
}; |
c39994410
|
44 45 46 |
export function signup( options ) { _validate( options.form, options.template ); } |