meteor create loginWithAuth
cd loginWithAuth
rm loginWithAuth.*
meteor add iron-router
<template name="home">
<h1>Hello buddies!</h1>
</template>
<template name="about">
<h1>about</h1>
</template>
Router.map(function() {
this.route('home', {
path: '/'
});
this.route('about');
});
admin
noAuth
loggingIn
Router.map(function() {
this.route('home', { path: '/' });
this.route('about');
this.route('admin');
this.route('noAuth');
});
Router.onBeforeAction(function(pause) {
var user;
user = Meteor.user();
if (!Meteor.loggingIn()) {
if (!(user && user.profile && user.profile.role === 'ADMIN')) {
Router.go('noAuth');
}
} else {
this.render('loggingIn');
pause();
}
}, {
only: ['admin']
});