fix(dev): rename superBlock with v7 to certSlug (#41738)
* fix(dev): rename superBlock with v7 to slug * improve name slug -> certSlug * superBlockTitle -> superBlock * correct teeny, tiny mistake * fix: correct slug to certSlug in certLocation * refactor currentCerts * rename showCert cert -> certSlug and various
This commit is contained in:
@ -15,7 +15,7 @@ import { getChallenges } from '../utils/get-curriculum';
|
||||
import {
|
||||
completionHours,
|
||||
certTypes,
|
||||
superBlockCertTypeMap,
|
||||
certSlugTypeMap,
|
||||
certTypeTitleMap,
|
||||
certTypeIdMap,
|
||||
certIds,
|
||||
@ -51,7 +51,7 @@ export default function bootCertificate(app) {
|
||||
const verifyCert = createVerifyCert(certTypeIds, app);
|
||||
|
||||
api.put('/certificate/verify', ifNoUser401, ifNoSuperBlock404, verifyCert);
|
||||
api.get('/certificate/showCert/:username/:cert', showCert);
|
||||
api.get('/certificate/showCert/:username/:certSlug', showCert);
|
||||
|
||||
app.use(api);
|
||||
}
|
||||
@ -66,9 +66,11 @@ export function getFallbackFrontEndDate(completedChallenges, completedDate) {
|
||||
return latestCertDate ? latestCertDate : completedDate;
|
||||
}
|
||||
|
||||
const certSlugs = Object.keys(certSlugTypeMap);
|
||||
|
||||
function ifNoSuperBlock404(req, res, next) {
|
||||
const { superBlock } = req.body;
|
||||
if (superBlock && superBlocks.includes(superBlock)) {
|
||||
const { certSlug } = req.body;
|
||||
if (certSlug && certSlugs.includes(certSlug)) {
|
||||
return next();
|
||||
}
|
||||
return res.status(404).end();
|
||||
@ -130,8 +132,6 @@ function getCertById(anId, allChallenges) {
|
||||
}))[0];
|
||||
}
|
||||
|
||||
const superBlocks = Object.keys(superBlockCertTypeMap);
|
||||
|
||||
function sendCertifiedEmail(
|
||||
{
|
||||
email = '',
|
||||
@ -223,11 +223,11 @@ function createVerifyCert(certTypeIds, app) {
|
||||
const { Email } = app.models;
|
||||
return function verifyCert(req, res, next) {
|
||||
const {
|
||||
body: { superBlock },
|
||||
body: { certSlug },
|
||||
user
|
||||
} = req;
|
||||
log(superBlock);
|
||||
let certType = superBlockCertTypeMap[superBlock];
|
||||
log(certSlug);
|
||||
let certType = certSlugTypeMap[certSlug];
|
||||
log(certType);
|
||||
return Observable.of(certTypeIds[certType])
|
||||
.flatMap(challenge => {
|
||||
@ -335,9 +335,9 @@ function createShowCert(app) {
|
||||
}
|
||||
|
||||
return function showCert(req, res, next) {
|
||||
let { username, cert } = req.params;
|
||||
let { username, certSlug } = req.params;
|
||||
username = username.toLowerCase();
|
||||
const certType = superBlockCertTypeMap[cert];
|
||||
const certType = certSlugTypeMap[certSlug];
|
||||
const certId = certTypeIdMap[certType];
|
||||
const certTitle = certTypeTitleMap[certType];
|
||||
const completionTime = completionHours[certType] || 300;
|
||||
|
Reference in New Issue
Block a user