My code that utilises the accounts-entry
package and manages authentication on routes
Last active
August 29, 2015 13:56
-
-
Save aaronthorp/9128311 to your computer and use it in GitHub Desktop.
Meteor.js - Iron-Router Login Controller. @aaronthorp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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