Blame view
imports/modules/reset-password.js
1.2 KB
7df77f0fa
|
1 2 |
import { getInputValue } from './get-input-value'; import { browserHistory } from 'react-router'; |
f0c912bf1
|
3 4 |
let component; let token; |
7df77f0fa
|
5 6 |
const _handleReset = () => { |
f0c912bf1
|
7 8 9 10 |
const password = getInputValue(component, 'newPassword', true); Accounts.resetPassword(token, password, (error) => { if (error) { Bert.alert(error.reason, 'danger'); |
7df77f0fa
|
11 |
} else { |
f0c912bf1
|
12 13 |
browserHistory.push('/'); Bert.alert('Password reset!', 'success'); |
7df77f0fa
|
14 15 16 17 18 |
} }); }; const _validate = () => { |
f0c912bf1
|
19 |
$(component.refs.resetPassword).validate({ |
7df77f0fa
|
20 21 22 |
rules: { newPassword: { required: true, |
f0c912bf1
|
23 |
minlength: 6, |
7df77f0fa
|
24 25 26 27 |
}, repeatNewPassword: { required: true, minlength: 6, |
f0c912bf1
|
28 29 |
equalTo: '[name="newPassword"]', }, |
7df77f0fa
|
30 31 32 |
}, messages: { newPassword: { |
f0c912bf1
|
33 34 |
required: 'Enter a new password, please.', minlength: 'Use at least six characters, please.', |
7df77f0fa
|
35 36 |
}, repeatNewPassword: { |
f0c912bf1
|
37 38 39 |
required: 'Repeat your new password, please.', equalTo: 'Hmm, your passwords don\'t match. Try again?', }, |
7df77f0fa
|
40 |
}, |
f0c912bf1
|
41 |
submitHandler() { _handleReset(); }, |
7df77f0fa
|
42 43 |
}); }; |
f0c912bf1
|
44 |
export const handleResetPassword = (options) => { |
7df77f0fa
|
45 |
component = options.component; |
f0c912bf1
|
46 |
token = options.token; |
7df77f0fa
|
47 48 |
_validate(); }; |