archive/hourglass/lib/router.js

58 lines
1.4 KiB
JavaScript
Raw Normal View History

Router.route('/', {
waitOn: function() {
if (!Meteor.userId()) {
this.redirect('/login');
} else {
return [
Meteor.subscribe('classes',this.params._id),
Meteor.subscribe('schools',this.params._id),
Meteor.subscribe('work',this.params._id),
Meteor.subscribe('users',this.params._id)
];
}
},
action: function() {
2016-08-12 17:18:30 -04:00
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', {
waitOn: function() {
if (!Meteor.userId()) {
this.redirect('/login');
} else {
return [
Meteor.subscribe('classes',this.params._id),
Meteor.subscribe('schools',this.params._id),
Meteor.subscribe('work',this.params._id),
Meteor.subscribe('users',this.params._id)
];
}
},
action: function() {
2016-08-12 17:18:30 -04:00
this.render("profile");
}
});
2016-08-16 06:15:15 -04:00
Router.route('/admin', function() {
if (Roles.userIsInRole(Meteor.userId(), ['admin', 'superadmin'])) {
this.render("admin");
} else {
this.redirect('/login');
}
});
2016-08-12 17:18:30 -04:00
Router.configure({
notFoundTemplate: "NotFound"
});