Blame view

imports/modules/recover-password.js 889 Bytes
852bfb60e   tmcdeveloper   swap Atmosphere p...
1
2
  import $ from 'jquery';
  import 'jquery-validation';
7df77f0fa   tmcdeveloper   finish wiring up ...
3
4
5
6
7
8
  import { getInputValue } from './get-input-value';
  
  let component;
  
  const _handleRecovery = () => {
    Accounts.forgotPassword({
f0c912bf1   tmcdeveloper   add method tests ...
9
10
11
12
      email: getInputValue(component, 'emailAddress', true),
    }, (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
18
19
      }
    });
  };
  
  const _validate = () => {
f0c912bf1   tmcdeveloper   add method tests ...
20
    $(component.refs.recoverPassword).validate({
7df77f0fa   tmcdeveloper   finish wiring up ...
21
22
23
      rules: {
        emailAddress: {
          required: true,
f0c912bf1   tmcdeveloper   add method tests ...
24
25
          email: true,
        },
7df77f0fa   tmcdeveloper   finish wiring up ...
26
27
28
29
      },
      messages: {
        emailAddress: {
          required: 'Need an email address here.',
f0c912bf1   tmcdeveloper   add method tests ...
30
31
          email: 'Is this email address legit?',
        },
7df77f0fa   tmcdeveloper   finish wiring up ...
32
      },
f0c912bf1   tmcdeveloper   add method tests ...
33
      submitHandler() { _handleRecovery(); },
7df77f0fa   tmcdeveloper   finish wiring up ...
34
35
    });
  };
f0c912bf1   tmcdeveloper   add method tests ...
36
  export const handleRecoverPassword = (options) => {
7df77f0fa   tmcdeveloper   finish wiring up ...
37
38
39
    component = options.component;
    _validate();
  };