archive/hourglass/lib/router.js

71 lines
2.0 KiB
JavaScript
Raw Normal View History

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