recover-password.js
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Controller: Recover Password
* Template: /client/views/public/recover-password.html
*/
/*
* Created
*/
Template.recoverPassword.onCreated(function(){
// Code to run when template is created goes here.
});
/*
* Rendered
*/
Template.recoverPassword.onRendered(function(){
$('#application-recover-password').validate({
rules: {
emailAddress: {
required: true,
email: true
}
},
messages: {
emailAddress: {
required: "Please enter your email address to recover your password.",
email: "Please enter a valid email address."
}
},
submitHandler: function(){
// Grab the user's email address.
var email = $('[name="emailAddress"]').val();
// Call the send reset password email method.
Accounts.forgotPassword({email: email}, function(error){
if(error){
Bert.alert(error.reason, 'danger');
} else {
Bert.alert('Check your inbox for a reset link!', 'success');
}
});
}
});
});
/*
* Helpers
*/
Template.recoverPassword.helpers({
example: function(){
// Code to run for helper function.
}
});
/*
* Events
*/
Template.recoverPassword.events({
'submit form': function(e){
// Prevent form from submitting.
e.preventDefault();
}
});