Blame view

imports/modules/recover-password.js 837 Bytes
7df77f0fa   tmcdeveloper   finish wiring up ...
1
2
3
4
5
6
  import { getInputValue } from './get-input-value';
  
  let component;
  
  const _handleRecovery = () => {
    Accounts.forgotPassword({
f0c912bf1   tmcdeveloper   add method tests ...
7
8
9
10
      email: getInputValue(component, 'emailAddress', true),
    }, (error) => {
      if (error) {
        Bert.alert(error.reason, 'warning');
7df77f0fa   tmcdeveloper   finish wiring up ...
11
      } else {
f0c912bf1   tmcdeveloper   add method tests ...
12
        Bert.alert('Check your inbox for a reset link!', 'success');
7df77f0fa   tmcdeveloper   finish wiring up ...
13
14
15
16
17
      }
    });
  };
  
  const _validate = () => {
f0c912bf1   tmcdeveloper   add method tests ...
18
    $(component.refs.recoverPassword).validate({
7df77f0fa   tmcdeveloper   finish wiring up ...
19
20
21
      rules: {
        emailAddress: {
          required: true,
f0c912bf1   tmcdeveloper   add method tests ...
22
23
          email: true,
        },
7df77f0fa   tmcdeveloper   finish wiring up ...
24
25
26
27
      },
      messages: {
        emailAddress: {
          required: 'Need an email address here.',
f0c912bf1   tmcdeveloper   add method tests ...
28
29
          email: 'Is this email address legit?',
        },
7df77f0fa   tmcdeveloper   finish wiring up ...
30
      },
f0c912bf1   tmcdeveloper   add method tests ...
31
      submitHandler() { _handleRecovery(); },
7df77f0fa   tmcdeveloper   finish wiring up ...
32
33
    });
  };
f0c912bf1   tmcdeveloper   add method tests ...
34
  export const handleRecoverPassword = (options) => {
7df77f0fa   tmcdeveloper   finish wiring up ...
35
36
37
    component = options.component;
    _validate();
  };