-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sanitize mentee public endpoint and sanitize mentor details (#150)
- Loading branch information
Showing
8 changed files
with
104 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { MenteeApplicationStatus, MentorApplicationStatus } from './enums' | |
import { generateCertificate } from './services/admin/generateCertificate' | ||
import { randomUUID } from 'crypto' | ||
import { certificatesDir } from './app' | ||
import type Mentee from './entities/mentee.entity' | ||
|
||
export const signAndSetCookie = (res: Response, uuid: string): void => { | ||
const token = jwt.sign({ userId: uuid }, JWT_SECRET ?? '') | ||
|
@@ -21,14 +22,45 @@ export const signAndSetCookie = (res: Response, uuid: string): void => { | |
} | ||
|
||
export const getMentorPublicData = (mentor: Mentor): Mentor => { | ||
const { application } = mentor | ||
const { application, profile } = mentor | ||
|
||
delete application.cv | ||
delete application.contactNo | ||
delete application.email | ||
delete application.motivation | ||
delete application.reasonToMentor | ||
|
||
delete profile.created_at | ||
delete profile.updated_at | ||
|
||
if (mentor.mentees) { | ||
mentor.mentees = mentor.mentees.map((mentee) => { | ||
return getMenteePublicData(mentee) | ||
}) | ||
} | ||
|
||
return mentor | ||
} | ||
|
||
export const getMenteePublicData = (mentee: Mentee): Mentee => { | ||
const { application, profile } = mentee | ||
|
||
delete application.cv | ||
delete application.contactNo | ||
delete application.email | ||
delete application.submission | ||
delete application.consentGiven | ||
|
||
delete profile.created_at | ||
delete profile.updated_at | ||
|
||
if (mentee.mentor) { | ||
mentee.mentor = getMentorPublicData(mentee.mentor) | ||
} | ||
|
||
return mentee | ||
} | ||
|
||
export const checkProfilePictureFileType = ( | ||
file: Express.Multer.File, | ||
cb: multer.FileFilterCallback | ||
|
@@ -101,7 +133,7 @@ export const getEmailContent = async ( | |
return { | ||
subject: 'Thank you very much for applying to ScholarX', | ||
message: `Dear ${name},<br /><br /> | ||
Thank you very much for applying to ScholarX. Your application has been received. Our team will soon review your application, and we will keep you posted on the progress via email. | ||
Thank you very much for applying to ScholarX. Your application has been received. Our team will soon review your application, and we will keep you posted on the progress via email. | ||
Please reach out to us via <a href="mailto:[email protected]">[email protected]</a> for any clarifications.` | ||
} | ||
case MentorApplicationStatus.APPROVED: | ||
|