Added NotFound for undefined user, and moved redirection to router

This commit is contained in:
Kenneth Jao 2016-09-10 14:06:22 -04:00
parent 725a72f21a
commit b480fa6558
2 changed files with 24 additions and 3 deletions

View File

@ -1079,8 +1079,8 @@ input, textarea {
#markDone p, #markConfirm p, #markReport p {
margin: 0;
display: inline;
}
}
#markDone, #markConfirm, #markReport {
padding: 5%;
background-color: rgba(0,0,0,0.1);
@ -1160,7 +1160,7 @@ input, textarea {
}
#userDropdownAvatar p {
width: 9vh;
width: 15vw;
margin: 0 auto 0 auto;
padding-top: 12vh;
text-align: center;

View File

@ -47,7 +47,6 @@ Router.route('/profile', {
});
Router.route('/user/:email', {
template: 'user',
data: function() {
return Meteor.users.findOne({'services.google.email': this.params.email});
},
@ -55,9 +54,31 @@ Router.route('/user/:email', {
return [
Meteor.subscribe('users', this.params._id)
];
},
action: function() {
if(Meteor.users.findOne({'services.google.email': this.params.email}) !== undefined) {
if(this.params.email === Meteor.user().services.google.email) {
this.redirect('/profile');
} else {
this.render('user');
}
} else {
this.render("NotFound");
}
}
});
/*Router.route('/admin', {
action: function() {
console.log("hi");
if (!Roles.userIsInRole(Meteor.userId(), ['admin', 'superadmin'])) {
this.redirect("/");
} else {
this.render("admin");
}
}
});*/
Router.configure({
notFoundTemplate: "NotFound"
});