Fix disable cert

Disable certificate when user is locked to the public
or when they haven't signed academic honesty
This commit is contained in:
Berkeley Martinez
2015-10-05 20:00:25 -07:00
parent 202d0fa068
commit 188da02ffc
2 changed files with 26 additions and 3 deletions

View File

@@ -103,7 +103,7 @@
"isLocked": {
"type": "boolean",
"default": false,
"description": "Campers profile does not show challenges to the public"
"description": "Campers profile does not show challenges/certificates to the public"
},
"currentChallenge": {
"type": {}

View File

@@ -4,6 +4,10 @@ import moment from 'moment';
import { Observable } from 'rx';
import debugFactory from 'debug';
import {
frontEndChallangeId,
fullStackChallangeId
} from '../utils/constantStrings.json';
import { ifNoUser401, ifNoUserRedirectTo } from '../utils/middleware';
import { observeQuery } from '../utils/rx';
@@ -270,14 +274,33 @@ module.exports = function(app) {
});
return res.redirect('/');
}
if (user.isLocked) {
req.flash('errors', {
msg: dedent`
Looks like user '${username}'s account is locked
down to the public.
`
});
return res.redirect('/');
}
if (!user.isHonest) {
req.flash('errors', {
msg: dedent`
Looks like the user '${username}'s has not signed
the academic honesty pledge.
`
});
return res.redirect('/');
}
if (
showFront && user.isFrontEndCert ||
!showFront && user.isFullStackCert
) {
var { completedDate } = _.find(user.completedChallenges, {
id: showFront ?
'561add10cb82ac38a17513be' :
'660add10cb82ac38a17513be'
frontEndChallangeId :
fullStackChallangeId
});
return res.render(