Skip to content

Instantly share code, notes, and snippets.

@aaronthorp
Last active August 29, 2015 13:56
Show Gist options
  • Save aaronthorp/9128311 to your computer and use it in GitHub Desktop.
Save aaronthorp/9128311 to your computer and use it in GitHub Desktop.
Meteor.js - Iron-Router Login Controller. @aaronthorp

Meteor.js - Iron-Router Login Controller

My code that utilises the accounts-entry package and manages authentication on routes

Support us via Gittip

LoginController = RouteController.extend({
before: [
function() {
NProgress.start();
}
],
after: function() {
var routeName = Router.current().route.name;
NProgress.done();
var thisPage = "entry";
if (_.isNull(Meteor.user()) && thisPage !== routeName.substring(0, thisPage.length)) {
console.log("LoginController: Redirect to login!");
//NProgress.done();
this.stop();
Router.go('entrySignIn');
}
}
});
Router.map(function() {
this.route('home', {
path: '/'
}),
this.route('dashboard', {
controller: 'LoginController',
path: '/dashboard'
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment