From 188da02ffcbf5a5709810495590888ed8f676325 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 5 Oct 2015 20:00:25 -0700 Subject: [PATCH] Fix disable cert Disable certificate when user is locked to the public or when they haven't signed academic honesty --- common/models/user.json | 2 +- server/boot/user.js | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/common/models/user.json b/common/models/user.json index cb34389b80..776c2c500e 100644 --- a/common/models/user.json +++ b/common/models/user.json @@ -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": {} diff --git a/server/boot/user.js b/server/boot/user.js index a7c6fe2978..9ecbe288dd 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -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(