Search code examples
javascriptpasswordsmeteoraccount

Does anyone know what this code means?


I'm trying to use this Meteor tutorial: https://waaave.com/tutorial/meteor/design-a-complete-authentication-system-with-meteor/#L11

I am confused at part 6.1. Does anyone know what the following means (this if from 6.1 of the tutorial)?

6.1. Make the forgot form appear. At the moment, if you click on the forgot password link nothing will happen and we have to change that. Each time we catch a click on this link, we will change the showForgotPassword session to true and return it with the showForgotPassword helper.

Template.main.helpers({
    showForgotPassword: function() {
        return Session.get('showForgotPassword');
    }
});

Template.signIn.events({
    'submit #signInForm': function(e, t) {
        ...
    },

    'click #showForgotPassword': function(e, t) {
        Session.set('showForgotPassword', true);
        return false;
    },
});

I tried using this but it either crashes my app or doesn't do anything at all. Can anybody help with this?


Solution

  • Session values are reactive values. Changes introduced to them cause dependents (like templates) to react to the changes.

    On the Template.main.helper, you have a helper named showForgotPassword which returns a session value named showForgotPassword. Clicking on the element with id #showForgotPassword will set the value of showForgotPassword session variable to true, which will cause reaction to the dependents.

    If nothing happens to your app, check if you misspelled any variable names and template dependencies. If it crashes, we cannot tell you since there's nothing in the code you provided that can cause a crash. It might be on another part of your code not shown here.