Blame view

imports/modules/recover-password.js 948 Bytes
4c9b3dfc1   themeteorchef   cleaning up
1
  /* eslint-disable no-undef */
cac7cbc73   tmcdeveloper   4.1.0 release
2
3
  import { Accounts } from 'meteor/accounts-base';
  import { Bert } from 'meteor/themeteorchef:bert';
4c9b3dfc1   themeteorchef   cleaning up
4
  import './validation.js';
7df77f0fa   tmcdeveloper   finish wiring up ...
5
6
  
  let component;
cac7cbc73   tmcdeveloper   4.1.0 release
7
  const handleRecovery = () => {
7df77f0fa   tmcdeveloper   finish wiring up ...
8
    Accounts.forgotPassword({
23c8a4c3c   themeteorchef   remove dependency...
9
      email: document.querySelector('[name="emailAddress"]').value,
f0c912bf1   tmcdeveloper   add method tests ...
10
11
12
    }, (error) => {
      if (error) {
        Bert.alert(error.reason, 'warning');
7df77f0fa   tmcdeveloper   finish wiring up ...
13
      } else {
f0c912bf1   tmcdeveloper   add method tests ...
14
        Bert.alert('Check your inbox for a reset link!', 'success');
7df77f0fa   tmcdeveloper   finish wiring up ...
15
16
17
      }
    });
  };
cac7cbc73   tmcdeveloper   4.1.0 release
18
  const validate = () => {
4c9b3dfc1   themeteorchef   cleaning up
19
    $(component.recoverPasswordForm).validate({
7df77f0fa   tmcdeveloper   finish wiring up ...
20
21
22
      rules: {
        emailAddress: {
          required: true,
f0c912bf1   tmcdeveloper   add method tests ...
23
24
          email: true,
        },
7df77f0fa   tmcdeveloper   finish wiring up ...
25
26
27
28
      },
      messages: {
        emailAddress: {
          required: 'Need an email address here.',
f0c912bf1   tmcdeveloper   add method tests ...
29
30
          email: 'Is this email address legit?',
        },
7df77f0fa   tmcdeveloper   finish wiring up ...
31
      },
cac7cbc73   tmcdeveloper   4.1.0 release
32
      submitHandler() { handleRecovery(); },
7df77f0fa   tmcdeveloper   finish wiring up ...
33
34
    });
  };
23c8a4c3c   themeteorchef   remove dependency...
35
  export default function handleRecoverPassword(options) {
7df77f0fa   tmcdeveloper   finish wiring up ...
36
    component = options.component;
cac7cbc73   tmcdeveloper   4.1.0 release
37
    validate();
23c8a4c3c   themeteorchef   remove dependency...
38
  }