2016-08-17 23:39:51 -04:00
|
|
|
Router.route('/', {
|
|
|
|
|
waitOn: function() {
|
2016-10-20 21:54:38 -04:00
|
|
|
if (!Meteor.userId()) {
|
2016-08-17 23:39:51 -04:00
|
|
|
this.redirect('/login');
|
|
|
|
|
} else {
|
|
|
|
|
return [
|
2016-09-04 20:20:40 -04:00
|
|
|
Meteor.subscribe('classes', this.params._id),
|
|
|
|
|
Meteor.subscribe('schools', this.params._id),
|
2016-11-08 20:19:22 -05:00
|
|
|
Meteor.subscribe('teachers', this.params._id),
|
2016-09-04 20:20:40 -04:00
|
|
|
Meteor.subscribe('work', this.params._id),
|
|
|
|
|
Meteor.subscribe('requests', this.params._id),
|
|
|
|
|
Meteor.subscribe('users', this.params._id)
|
2016-08-17 23:39:51 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-09-01 00:13:17 -04:00
|
|
|
action: function() {
|
2016-11-07 17:26:02 -05:00
|
|
|
if(_.contains([null, undefined, ""], Meteor.user().profile.school ||
|
|
|
|
|
_.contains([null, undefined, ""], Meteor.user().profile.grade))) {
|
|
|
|
|
this.redirect('/profile');
|
2016-10-20 21:54:38 -04:00
|
|
|
} else {
|
2016-10-23 22:11:27 -04:00
|
|
|
Session.set("user", Meteor.user().profile);
|
2016-10-20 21:54:38 -04:00
|
|
|
this.render("main");
|
|
|
|
|
}
|
2016-08-12 17:18:30 -04:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-10-11 00:12:24 -04:00
|
|
|
Router.route('/login', {
|
|
|
|
|
action: function() {
|
|
|
|
|
if (!Meteor.userId()) {
|
|
|
|
|
this.render("login");
|
|
|
|
|
} else if (!Meteor.user().profile.school) {
|
2016-10-23 22:11:27 -04:00
|
|
|
Session.set("user", Meteor.user().profile);
|
2016-10-11 00:12:24 -04:00
|
|
|
this.redirect('/profile');
|
|
|
|
|
} else {
|
2016-10-23 22:11:27 -04:00
|
|
|
Session.set("user", Meteor.user().profile);
|
2016-10-11 00:12:24 -04:00
|
|
|
this.redirect('/');
|
|
|
|
|
}
|
2016-08-12 17:18:30 -04:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-17 23:39:51 -04:00
|
|
|
Router.route('/profile', {
|
|
|
|
|
waitOn: function() {
|
|
|
|
|
if (!Meteor.userId()) {
|
|
|
|
|
this.redirect('/login');
|
|
|
|
|
} else {
|
|
|
|
|
return [
|
2016-09-04 20:20:40 -04:00
|
|
|
Meteor.subscribe('classes', this.params._id),
|
|
|
|
|
Meteor.subscribe('schools', this.params._id),
|
2016-11-08 20:19:22 -05:00
|
|
|
Meteor.subscribe('teachers', this.params._id),
|
2016-09-04 20:20:40 -04:00
|
|
|
Meteor.subscribe('work', this.params._id),
|
|
|
|
|
Meteor.subscribe('requests', this.params._id),
|
|
|
|
|
Meteor.subscribe('users', this.params._id)
|
2016-08-17 23:39:51 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-09-04 20:20:40 -04:00
|
|
|
action: function() {
|
2016-10-23 22:11:27 -04:00
|
|
|
Session.set("user", Meteor.user().profile);
|
2016-08-12 17:18:30 -04:00
|
|
|
this.render("profile");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Router.configure({
|
2016-10-11 00:12:24 -04:00
|
|
|
notFoundTemplate: "NotFound"
|
2016-09-01 00:13:17 -04:00
|
|
|
});
|