Harden showCert against errors

pull/3657/head
Berkeley Martinez 2015-10-08 08:48:52 -07:00
parent aaac06fda3
commit ba88def035
1 changed files with 7 additions and 6 deletions

View File

@ -319,11 +319,12 @@ module.exports = function(app) {
showFront && user.isFrontEndCert ||
!showFront && user.isFullStackCert
) {
var { completedDate } = _.find(user.completedChallenges, {
id: showFront ?
frontEndChallangeId :
fullStackChallangeId
});
var { completedDate = new Date() } =
_.find(user.completedChallenges, {
id: showFront ?
frontEndChallangeId :
fullStackChallangeId
}) || {};
return res.render(
showFront ?
@ -342,7 +343,7 @@ module.exports = function(app) {
`Looks like user ${username} is not Front End certified` :
`Looks like user ${username} is not Full Stack certified`
});
res.redirect('/map');
res.redirect('back');
},
next
);