Blame view

client/modules/reset-password.js 1.12 KB
db5aba845   Ryan Glover   miscellaneous wor...
1
2
3
4
  let template;
  
  let _handleReset = () => {
    var token    = FlowRouter.getParam( 'token' ),
c39994410   Ryan Glover   wip converting to...
5
        password = template.find( '[name="newPassword"]' ).value;
0ccda7775   Ryan Glover   add support for E...
6

c39994410   Ryan Glover   wip converting to...
7
8
9
10
11
12
13
    Accounts.resetPassword( token, password, ( error ) => {
      if ( error ) {
        Bert.alert( error.reason, 'danger' );
      } else {
        Bert.alert( 'Password reset!', 'success' );
      }
    });
0ccda7775   Ryan Glover   add support for E...
14
  };
db5aba845   Ryan Glover   miscellaneous wor...
15
  let validation = () => {
0ccda7775   Ryan Glover   add support for E...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    return {
      rules: {
        newPassword: {
          required: true,
          minlength: 6
        },
        repeatNewPassword: {
          required: true,
          minlength: 6,
          equalTo: '[name="newPassword"]'
        }
      },
      messages: {
        newPassword: {
db5aba845   Ryan Glover   miscellaneous wor...
30
31
          required: 'Enter a new password, please.',
          minlength: 'Use at least six characters, please.'
0ccda7775   Ryan Glover   add support for E...
32
33
        },
        repeatNewPassword: {
db5aba845   Ryan Glover   miscellaneous wor...
34
35
          required: 'Repeat your new password, please.',
          equalTo: 'Hmm, your passwords don\'t match. Try again?'
0ccda7775   Ryan Glover   add support for E...
36
37
        }
      },
db5aba845   Ryan Glover   miscellaneous wor...
38
      submitHandler() { _handleReset(); }
0ccda7775   Ryan Glover   add support for E...
39
40
    };
  };
db5aba845   Ryan Glover   miscellaneous wor...
41
42
  let _validate = ( form ) => {
    $( form ).validate( validation() );
0ccda7775   Ryan Glover   add support for E...
43
  };
db5aba845   Ryan Glover   miscellaneous wor...
44
45
46
  export default function ( options ) {
    template = options.template;
    _validate( options.form );
c39994410   Ryan Glover   wip converting to...
47
  }