recover-password.js
861 Bytes
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
let _handleRecovery = ( template ) => {
let email = template.find( '[name="emailAddress"]' ).value;
Accounts.forgotPassword( { email: email }, ( error ) => {
if ( error ) {
Bert.alert( error.reason, 'warning' );
} else {
Bert.alert( 'Check your inbox for a reset link!', 'success' );
}
});
};
let validation = ( template ) => {
return {
rules: {
emailAddress: {
required: true,
email: true
}
},
messages: {
emailAddress: {
required: 'Need an email address here.',
email: 'Is this email address legit?'
}
},
submitHandler() { _handleRecovery( template ); }
};
};
let _validate = ( form, template ) => {
$( form ).validate( validation( template ) );
};
export function recoverPassword( options ) {
_validate( options.form, options.template );
}