mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor: use cert as key (#64293)
This commit is contained in:
committed by
GitHub
parent
73ad631dfd
commit
9d8cbcff5a
@@ -6,7 +6,7 @@ import { getChallenges } from '../../utils/get-challenges.js';
|
||||
import {
|
||||
certIds,
|
||||
certSlugTypeMap,
|
||||
certTypeTitleMap,
|
||||
certToTitleMap,
|
||||
certTypes,
|
||||
currentCertifications,
|
||||
legacyCertifications,
|
||||
@@ -298,7 +298,7 @@ export const protectedCertificateRoutes: FastifyPluginCallbackTypebox = (
|
||||
}
|
||||
|
||||
const certType = certSlugTypeMap[certSlug];
|
||||
const certName = certTypeTitleMap[certType];
|
||||
const certName = certToTitleMap[certSlug];
|
||||
|
||||
const user = await fastify.prisma.user.findUnique({
|
||||
where: { id: req.user?.id }
|
||||
|
||||
@@ -4,7 +4,7 @@ import { find } from 'lodash-es';
|
||||
import * as schemas from '../../schemas.js';
|
||||
import {
|
||||
certSlugTypeMap,
|
||||
certTypeTitleMap,
|
||||
certToTitleMap,
|
||||
certTypeIdMap,
|
||||
completionHours,
|
||||
oldDataVizId
|
||||
@@ -53,7 +53,7 @@ export const unprotectedCertificateRoutes: FastifyPluginCallbackTypebox = (
|
||||
|
||||
const certType = certSlugTypeMap[certSlug];
|
||||
const certId = certTypeIdMap[certType];
|
||||
const certTitle = certTypeTitleMap[certType];
|
||||
const certTitle = certToTitleMap[certSlug];
|
||||
const completionTime = completionHours[certType] || 300;
|
||||
const user = await fastify.prisma.user.findFirst({
|
||||
where: { username },
|
||||
@@ -180,16 +180,15 @@ export const unprotectedCertificateRoutes: FastifyPluginCallbackTypebox = (
|
||||
}
|
||||
|
||||
if (!user[certType]) {
|
||||
const cert = certTypeTitleMap[certType];
|
||||
logger.info(
|
||||
`User ${username} has not completed the ${cert} certification.`
|
||||
`User ${username} has not completed the ${certTitle} certification.`
|
||||
);
|
||||
return reply.send({
|
||||
messages: [
|
||||
{
|
||||
type: 'info',
|
||||
message: 'flash.user-not-certified',
|
||||
variables: { username, cert }
|
||||
variables: { username, cert: certTitle }
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user