archive/hourglass/lib/router.js
Yaman Qalieh a329b4b08e tabbing
2016-09-08 17:11:35 -04:00

83 lines
2.3 KiB
JavaScript

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('requests', this.params._id),
Meteor.subscribe('users', this.params._id)
];
}
},
action: function() {
this.render("main");
}
});
Router.route('/login', function() {
if (!Meteor.userId()) {
this.render("login");
} else if (!Meteor.user().profile.school) {
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() {
this.render("profile");
}
});
Router.route('/user/:email', {
template: 'user',
data: function() {
return Meteor.users.findOne({'services.google.email': this.params.email});
},
waitOn: function() {
return [
Meteor.subscribe('users', this.params._id)
];
}
});
// Router.route('/admin', {
// waitOn: function() {
// 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() {
// if (!Roles.userIsInRole(Meteor.userId(), ['admin', 'superadmin'])) {
// this.render("NotFound");
// } else {
// this.render("admin");
// }
// }
// });
Router.configure({
notFoundTemplate: "NotFound"
});