fix #76
This commit is contained in:
parent
80126c4631
commit
e23398999a
@ -1,6 +1,6 @@
|
|||||||
Router.route('/', {
|
Router.route('/', {
|
||||||
waitOn: function() {
|
waitOn: function() {
|
||||||
if (!Meteor.userId()) {
|
if (!Meteor.userId() || !Meteor.user().profile.school) {
|
||||||
this.redirect('/login');
|
this.redirect('/login');
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
@ -12,7 +12,7 @@ Router.route('/', {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
action: function() {
|
action: function() {
|
||||||
this.render("main");
|
this.render("main");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -20,7 +20,7 @@ Router.route('/', {
|
|||||||
Router.route('/login', function() {
|
Router.route('/login', function() {
|
||||||
if (!Meteor.userId()) {
|
if (!Meteor.userId()) {
|
||||||
this.render("login");
|
this.render("login");
|
||||||
} else if (Object.keys(Meteor.user().profile).length <= 1) {
|
} else if (!Meteor.user().profile.school) {
|
||||||
this.redirect('/profile');
|
this.redirect('/profile');
|
||||||
} else {
|
} else {
|
||||||
this.redirect('/');
|
this.redirect('/');
|
||||||
@ -67,4 +67,4 @@ Router.route('/admin', {
|
|||||||
|
|
||||||
Router.configure({
|
Router.configure({
|
||||||
notFoundTemplate: "NotFound"
|
notFoundTemplate: "NotFound"
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import {
|
|||||||
} from 'meteor/mongo';
|
} from 'meteor/mongo';
|
||||||
|
|
||||||
// Defines who the admins are - not added
|
// Defines who the admins are - not added
|
||||||
|
|
||||||
var superadmins = [
|
var superadmins = [
|
||||||
"ybq987@gmail.com",
|
"ybq987@gmail.com",
|
||||||
"ksjdragon@gmail.com",
|
"ksjdragon@gmail.com",
|
||||||
@ -40,14 +39,14 @@ Meteor.publish('classes', function() {
|
|||||||
return classes.find();
|
return classes.find();
|
||||||
} else {
|
} else {
|
||||||
// Return user classes and all _public_ classes.
|
// Return user classes and all _public_ classes.
|
||||||
var userprofile = Meteor.users.findOne(this.userId).profile;
|
var userprofile = Meteor.users.findOne(this.userId);
|
||||||
if (userprofile !== undefined && userprofile.classes !== undefined) {
|
if (userprofile !== undefined && userprofile.profile.classes !== undefined) {
|
||||||
return classes.find({
|
return classes.find({
|
||||||
$or: [{
|
$or: [{
|
||||||
privacy: false
|
privacy: false
|
||||||
}, {
|
}, {
|
||||||
_id: {
|
_id: {
|
||||||
$in: userprofile.classes
|
$in: userprofile.profile.classes
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
@ -67,11 +66,8 @@ Meteor.publish('classes', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var empty;
|
Meteor.call('createProfile', this.userId);
|
||||||
Meteor.call('createProfile', this.userId, function(error, result) {
|
return classes.find({_id: null});
|
||||||
empty = result;
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -82,20 +78,17 @@ Meteor.publish('work', function() {
|
|||||||
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(this.userId, ['superadmin', 'admin'])) {
|
||||||
return work.find();
|
return work.find();
|
||||||
} else {
|
} else {
|
||||||
var userprofile = Meteor.users.findOne(this.userId).profile;
|
var userprofile = Meteor.users.findOne(this.userId);
|
||||||
if (userprofile !== undefined && userprofile.classes !== undefined) {
|
if (userprofile !== undefined && userprofile.profile.classes !== undefined) {
|
||||||
return work.find({
|
return work.find({
|
||||||
// Only return work of enrolled classes
|
// Only return work of enrolled classes
|
||||||
class: {
|
class: {
|
||||||
$in: userprofile.classes
|
$in: userprofile.profile.classes
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var empty;
|
Meteor.call('createProfile', this.userId);
|
||||||
Meteor.call('createProfile', this.userId, function(error, result) {
|
return classes.find({_id: null});
|
||||||
empty = result;
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -518,9 +511,6 @@ Meteor.methods({
|
|||||||
profile: current
|
profile: current
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return classes.find({
|
|
||||||
_id: null
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
'joinClass': function(input) {
|
'joinClass': function(input) {
|
||||||
var change = input[0];
|
var change = input[0];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user