Javascript 登录时呈现模板?

Javascript 登录时呈现模板?,javascript,templates,meteor,account,iron-router,Javascript,Templates,Meteor,Account,Iron Router,我正在使用meteor和iron router,我希望当用户成功登录时,应用程序自动转到“仪表板”模板。我该怎么做?这是我的密码: javascript: // Sign In Template Template.signIn.events({ 'submit #signInForm': function(e, t) { e.preventDefault(); var signInForm = $(e.currentTarget),

我正在使用meteor和iron router,我希望当用户成功登录时,应用程序自动转到“仪表板”模板。我该怎么做?这是我的密码:

javascript:

// Sign In Template
Template.signIn.events({
    'submit #signInForm': function(e, t) {
        e.preventDefault();

        var signInForm = $(e.currentTarget),
            email = trimInput(signInForm.find('.email').val().toLowerCase()),
            password = signInForm.find('.password').val();

        if (isNotEmpty(email) && isEmail(email) && isNotEmpty(password) && isValidPassword(password)) {
            Meteor.loginWithPassword(email, password, function(err) {
                if (err) {
                    Session.set('alert', 'We\'re sorry but these credentials are not valid.');
                } else {
                    Sesson.set('alert', 'Welcome back New Meteorite!');


                }
            });
        }
        return false;
    },
});

在成功的情况下,您可以通过
登录并使用密码
,只需调用:

Router.go('dashboard');
这是假设您有一个名为
dashboard
的路由。例如:

Router.map(function () {
  this.route('dashboard', {
    path: '/user/dashboard',
    template: 'userDashboard'
  });
来自atmosphere的软件包可以帮助您以一种视觉上吸引人的无缝方式实现这一点

如以下示例所述:

Meteor.startup(function() {
  return AccountsEntry.config({
    logo: 'logo.png',
    privacyUrl: '/privacy-policy',
    termsUrl: '/terms-of-use',
    homeRoute: '/',
    dashboardRoute: '/dashboard', // you have an autoconfigured dashboard route
    profileRoute: 'profile',
    passwordSignupFields: 'EMAIL_ONLY',
    showSignupCode: true
  });
});
为了保护您的路由,您只需配置:

Route.map(function() {
  this.route('createPayment', {
    path: '/create/payment',
    before: function() {
      return AccountsEntry.signInRequired(this);
    }
  });
});