diff --git a/hourglass/lib/router.js b/hourglass/lib/router.js new file mode 100644 index 0000000..218a7d1 --- /dev/null +++ b/hourglass/lib/router.js @@ -0,0 +1,29 @@ +Router.route('/', function() { + if (!Meteor.userId()) { + this.redirect('/login'); + } else { + this.render("main"); + } +}); + +Router.route('/login', function() { + if (!Meteor.userId()) { + this.render("login"); + } else if (Object.keys(Meteor.user().profile).length <= 1) { + this.redirect('/profile'); + } else { + this.redirect('/'); + } +}); + +Router.route('/profile', function() { + if (!Meteor.userId()) { + this.redirect("/login"); + } else { + this.render("profile"); + } +}); + +Router.configure({ + notFoundTemplate: "NotFound" +});