At that point (6.1) in the tutorial, you have not yet configured any event handlers for the forgotPassword
. It is not working because the code is not there yet.
In the following section, 6.2, the author walks you through sending an email for initiating password recovery:
Template.forgotPassword.events({
'submit #forgotPasswordForm': function(e, t) {
e.preventDefault();
var forgotPasswordForm = $(e.currentTarget),
email = trimInput(forgotPasswordForm.find('#forgotPasswordEmail').val().toLowerCase());
if (isNotEmpty(email) && isEmail(email)) {
Accounts.forgotPassword({email: email}, function(err) {
if (err) {
if (err.message === 'User not found [403]') {
Session.set('alert', 'This email does not exist.');
} else {
Session.set('alert', 'We\'re sorry but something went wrong.');
}
} else {
Session.set('alert', 'Email Sent. Please check your mailbox to reset your password.');
}
});
}
return false;
},
'click #returnToSignIn': function(e, t) {
Session.set('showForgotPassword', null);
return false;
},
});
This is a common pattern I've been seeing in recent tutorials.
Instead of giving you a complete app in the beginning and breaking it down, the authors take an iterative approach and build the app piece by piece, which is what you normally would do if you were to build the app.
So it works perfectly as a tutorial. Just be patient until the end :)
UPDATE: Th forgot password form is not showing up because it is supposed to be within a template called main as seen in this code:
<template name="main">
{{> alert}}
{{#unless resetPassword}}
{{#unless currentUser}}
{{#unless showForgotPassword}}
{{> signIn}}
{{> signUp}}
{{else}}
{{> forgotPassword}}
{{/unless}}
{{else}}
{{> signOut}}
{{/unless}}
{{else}}
{{> resetPassword}}
{{/unless}}
</template>
and the following helper takes the session paramater and feeds it to the unless
block:
Template.main.helpers({
showForgotPassword: function() {
return Session.get('showForgotPassword');
}
});
but your code does not have that main
template, instead you wrapped your code in a generic div
and you also seem to have changed some other portions of the code.
<div id="topbar">
{{> signOut}}
{{#unless resetPassword}}
{{#unless currentUser}}
{{#unless showForgotPassword}}
{{else}}
{{> forgotPassword}}
{{/unless}}
{{else}}
{{/unless}}
{{else}}
{{> resetPassword}}
{{/unless}}
</div>
Therefore, you can either use the original code from the tutorial, or if you really want to change that code, you can wrap your topbar div
with a main template
as seen in the original code.