recover-password.js
944 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
38
39
40
41
import $ from 'jquery';
import 'jquery-validation';
import { Accounts } from 'meteor/accounts-base';
import { Bert } from 'meteor/themeteorchef:bert';
let component;
const handleRecovery = () => {
Accounts.forgotPassword({
email: document.querySelector('[name="emailAddress"]').value,
}, (error) => {
if (error) {
Bert.alert(error.reason, 'warning');
} else {
Bert.alert('Check your inbox for a reset link!', 'success');
}
});
};
const validate = () => {
$(component.refs.recoverPassword).validate({
rules: {
emailAddress: {
required: true,
email: true,
},
},
messages: {
emailAddress: {
required: 'Need an email address here.',
email: 'Is this email address legit?',
},
},
submitHandler() { handleRecovery(); },
});
};
export default function handleRecoverPassword(options) {
component = options.component;
validate();
}