mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-26 17:02:27 -04:00
fix: use env.ts to get JWT_SECRET (#51424)
This commit is contained in:
committed by
GitHub
parent
cb9d6a6243
commit
567cbfc044
@@ -1,12 +1,12 @@
|
||||
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { uniqBy } from 'lodash';
|
||||
import { jwtSecret } from '../../../api-server/config/secrets';
|
||||
import { getChallenges } from '../utils/get-challenges';
|
||||
import { updateUserChallengeData } from '../utils/common-challenge-functions';
|
||||
import { formatValidationError } from '../utils/error-formatting';
|
||||
import { schemas } from '../schemas';
|
||||
import { getPoints, ProgressTimestamp } from '../utils/progress';
|
||||
import { JWT_SECRET } from '../utils/env';
|
||||
import { challengeTypes } from '../../../config/challenge-types';
|
||||
import {
|
||||
canSubmitCodeRoadCertProject,
|
||||
@@ -65,8 +65,11 @@ export const challengeRoutes: FastifyPluginCallbackTypebox = (
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof encodedUserToken === 'string' && jwtSecret) {
|
||||
const payload = jwt.verify(encodedUserToken, jwtSecret) as JwtPayload;
|
||||
if (typeof encodedUserToken === 'string') {
|
||||
const payload = jwt.verify(
|
||||
encodedUserToken,
|
||||
JWT_SECRET
|
||||
) as JwtPayload;
|
||||
userToken = payload.userToken;
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user