change routing

This commit is contained in:
Yaman Qalieh 2016-08-12 17:18:30 -04:00
parent 8a34c1ab09
commit 08b1b1ef6d

29
hourglass/lib/router.js Normal file
View File

@ -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"
});