MCPcopy Index your code
hub / github.com/freeCodeCamp/freeCodeCamp / getSessionUserHandler

Function getSessionUserHandler

api/src/routes/protected/user.ts:721–906  ·  view source on GitHub ↗
(
    req: UpdateReqType<typeof schemas.getSessionUser>,
    res: FastifyReply
  )

Source from the content-addressed store, hash-verified

719 done
720) => {
721 const getSessionUserHandler = async (
722 req: UpdateReqType<typeof schemas.getSessionUser>,
723 res: FastifyReply
724 ) => {
725 const logger = fastify.log.child({ req, res });
726 // This is one of the most requested routes. To avoid spamming the logs
727 // with this route, we'll log requests at the debug level.
728 logger.debug({ userId: req.user?.id });
729
730 // Handle unauthenticated users - this is not an error, it's how the client
731 // determines if they are signed in or not
732 if (!req.user?.id) {
733 logger.debug('Unauthenticated user requested session');
734 return { user: {}, result: '' };
735 }
736
737 try {
738 const userTokenP = fastify.prisma.userToken.findFirst({
739 where: { userId: req.user.id }
740 });
741
742 const userP = fastify.prisma.user.findUnique({
743 where: { id: req.user.id },
744 select: {
745 about: true,
746 acceptedPrivacyTerms: true,
747 completedChallenges: true,
748 completedDailyCodingChallenges: true,
749 completedExams: true,
750 currentChallengeId: true,
751 quizAttempts: true,
752 email: true,
753 emailVerified: true,
754 githubProfile: true,
755 id: true,
756 is2018DataVisCert: true,
757 is2018FullStackCert: true,
758 isA2EnglishCert: true,
759 isApisMicroservicesCert: true,
760 isBackEndCert: true,
761 isCheater: true,
762 isCollegeAlgebraPyCertV8: true,
763 isDataAnalysisPyCertV7: true,
764 isDataVisCert: true,
765 isDonating: true,
766 isFoundationalCSharpCertV8: true,
767 isFrontEndCert: true,
768 isFrontEndLibsCert: true,
769 isFullStackCert: true,
770 isClassroomAccount: true,
771 isHonest: true,
772 isInfosecCertV7: true,
773 isInfosecQaCert: true,
774 isJavascriptCertV9: true,
775 isJsAlgoDataStructCert: true,
776 isJsAlgoDataStructCertV8: true,
777 isMachineLearningPyCertV7: true,
778 isPythonCertV9: true,

Callers

nothing calls this directly

Calls 12

encodeUserTokenFunction · 0.85
splitUserFunction · 0.85
removeNullsFunction · 0.85
normalizeFlagsFunction · 0.85
normalizeChallengesFunction · 0.85
getCalendarFunction · 0.85
getPointsFunction · 0.85
normalizeProfileUIFunction · 0.85
normalizeTwitterFunction · 0.85
normalizeBlueskyFunction · 0.85
normalizeSurveysFunction · 0.85
sendMethod · 0.45

Tested by

no test coverage detected