Go Pro Sign Up Login
0 days 0 hrs 0 min 0 sec

Summer Sale

50% off Level Up Pro until you unsubscribe.
Get access to ALL 128 courses on Level Up Tutorials

This is your last chance to get Level Up Pro for $145/year.

or Learn More
Moon Moon

Buy Now and unlock this series

yours forever

Become a Pro and unlock everything

$

24

.99

per month

Login & Logout Redirecting

In this Intermediate Meteor video tutorial, we write redirects to make sure the user is landing on the correct page when logging in or out. Subscribe for more free tutorials https://goo.gl/6ljoFc, more Intermediate Tutorials here: https://goo.gl/11JLL8

Downloads

Become a pro to download code and videos

Comments

Gary Porter

about 2 years ago [edited]

I found if you include this in your main.js

Tracker.autorun(()=>{ if(!Meteor.userId()){ FlowRouter.go('home'); } else{ FlowRouter.go('recipe-book'); } });

it should work but you get a Malformed URI warning in console

Christian

almost 3 years ago [edited]

onLogin and onLogout apparently don't work anymore. The package auth-callbacks is no longer maintained and apparently doesn't work anymore. I've tried a couple of different ways to make it work but the callbacks simply are not being called anymore as of Meteor 1.8 (2019) What I did was simply add the SideNav to the HomeLayout and only rendering it when the user has loggedIn:

<template name='HomeLayout'>
    {{> Header}}
    {{#if loggedIn}}
    {{> SideNav}}
    {{/if}}
    <main>
        <div class="billboard">
            <h2>Organize Your Meals</h2>
        </div>
    </main>
</template>

Want to join the conversation?

Become a Pro member today!