Merge pull request #3657 from FreeCodeCamp/fix/harded-certs
Harden showCert against errors
This commit is contained in:
@ -321,11 +321,12 @@ module.exports = function(app) {
|
|||||||
showFront && user.isFrontEndCert ||
|
showFront && user.isFrontEndCert ||
|
||||||
!showFront && user.isFullStackCert
|
!showFront && user.isFullStackCert
|
||||||
) {
|
) {
|
||||||
var { completedDate } = _.find(user.completedChallenges, {
|
var { completedDate = new Date() } =
|
||||||
|
_.find(user.completedChallenges, {
|
||||||
id: showFront ?
|
id: showFront ?
|
||||||
frontEndChallangeId :
|
frontEndChallangeId :
|
||||||
fullStackChallangeId
|
fullStackChallangeId
|
||||||
});
|
}) || {};
|
||||||
|
|
||||||
return res.render(
|
return res.render(
|
||||||
showFront ?
|
showFront ?
|
||||||
@ -344,7 +345,7 @@ module.exports = function(app) {
|
|||||||
`Looks like user ${username} is not Front End certified` :
|
`Looks like user ${username} is not Front End certified` :
|
||||||
`Looks like user ${username} is not Full Stack certified`
|
`Looks like user ${username} is not Full Stack certified`
|
||||||
});
|
});
|
||||||
res.redirect('/map');
|
res.redirect('back');
|
||||||
},
|
},
|
||||||
next
|
next
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user