Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c314da8
init mentoring system
heryandjaruma Jul 18, 2025
3bbbfea
add book mentorship endpoint
heryandjaruma Jul 18, 2025
2ffce10
add get my mentorships
heryandjaruma Jul 18, 2025
c06a770
add get mentor by mentorId
heryandjaruma Jul 18, 2025
29c5997
add get role endpoint
heryandjaruma Jul 18, 2025
03a4c11
add mentorship config endpoint
heryandjaruma Jul 18, 2025
da0f5c3
minor fix controller
heryandjaruma Jul 18, 2025
5e808ca
add upcomingOnly
heryandjaruma Jul 19, 2025
9e44d9b
add luxon, handle get upcoming mentorships only
heryandjaruma Jul 19, 2025
8fc55df
add upcomingOnly and recentOnly
heryandjaruma Jul 19, 2025
0f8ec49
edit model and types
heryandjaruma Jul 20, 2025
d04fe5a
add isMentor middleware
heryandjaruma Jul 20, 2025
a986d59
add my mentorships mentorship
heryandjaruma Jul 20, 2025
8c56709
edit config type
heryandjaruma Jul 20, 2025
3ca63ba
mentor get my mentorships endpoint
heryandjaruma Jul 20, 2025
3b6c6be
add mentor Get my mentorship
heryandjaruma Jul 20, 2025
f23b488
update firebase function
heryandjaruma Jul 20, 2025
34c546b
mentor update mentorship
heryandjaruma Jul 20, 2025
ca6e911
add get mentors
heryandjaruma Jul 20, 2025
de8fcaf
add limit
heryandjaruma Jul 20, 2025
3b5db62
add get mentor
heryandjaruma Jul 20, 2025
bf51a91
add concurrently
heryandjaruma Jul 20, 2025
31b3778
add get mentorship schedules
heryandjaruma Jul 20, 2025
28e1747
add get mentorship schedule
heryandjaruma Jul 20, 2025
4437c7d
add book mentorship endponts
heryandjaruma Jul 20, 2025
a8e0fe9
add cancel mentorship endpoint
heryandjaruma Jul 20, 2025
67210c1
add get my mentorship hacker
heryandjaruma Jul 20, 2025
a606008
minor fix book mentorship
heryandjaruma Jul 20, 2025
d4f92b0
add hacker get my mentorship endpoint
heryandjaruma Jul 21, 2025
18f0301
minor fix
heryandjaruma Jul 21, 2025
f485563
remove unused code
heryandjaruma Jul 21, 2025
5c35b3b
add validation before book mentorship
heryandjaruma Jul 21, 2025
4913985
minor fix return data mentor
heryandjaruma Jul 21, 2025
8e897a7
minor fix add check 25 mins
heryandjaruma Jul 21, 2025
10575b9
minor fix add limit
heryandjaruma Jul 21, 2025
5a21a21
add check for mentorship is open
heryandjaruma Jul 22, 2025
8f3046a
success send email mentor for booking
heryandjaruma Jul 22, 2025
5656e7f
add cancel book mentor
heryandjaruma Jul 22, 2025
a781041
add available field to hacker fetch mentors
heryandjaruma Jul 23, 2025
172fcf2
edit mask data
heryandjaruma Jul 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 102 additions & 8 deletions functions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"lint": "eslint --ext .js,.ts .",
"build": "tsc",
"build:watch": "tsc --watch --preserveWatchOutput",
"serve": "npm run build:watch | firebase emulators:start",
"serve": "concurrently \"npm:build:watch\" \"firebase emulators:start\"",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
Expand All @@ -23,25 +23,28 @@
"dotenv": "^16.4.7",
"express": "^4.21.2",
"firebase-admin": "^12.7.0",
"firebase-functions": "^6.3.2",
"firebase-functions": "^6.4.0",
"jsonwebtoken": "^9.0.2",
"lodash": "^4.17.21",
"luxon": "^3.7.1",
"nodemailer": "^7.0.3",
"validator": "^13.15.0"
},
"devDependencies": {
"@faker-js/faker": "^9.6.0",
"@types/busboy": "^1.5.4",
"@types/cookie-parser": "^1.4.8",
"@types/cookie-parser": "^1.4.9",
"@types/cors": "^2.8.18",
"@types/csurf": "^1.11.5",
"@types/express": "^5.0.1",
"@types/jsonwebtoken": "^9.0.9",
"@types/lodash": "^4.17.16",
"@types/luxon": "^3.6.2",
"@types/nodemailer": "^6.4.17",
"@types/validator": "^13.12.2",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"concurrently": "^9.2.0",
"eslint": "^8.9.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^10.1.1",
Expand Down
46 changes: 46 additions & 0 deletions functions/src/controllers/auth_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,3 +715,49 @@ export const verifyAccount = async (
});
}
};

export const getCurrentUserRole = async (
req: Request,
res: Response
): Promise<void> => {
try {
/**
* Check request:
* 1. Cookie must be present in header.
*/
const uid = req.user?.uid
if (req.user === undefined) {
res.status(401).json({
status: 401,
error: "Unauthorized"
})
return;
}
if (!uid || uid === undefined) {
res.status(401).json({
status: 401,
error: "Unauthorized"
})
return;
}

/**
* Process request:
* 1. Get claims of a user. If none, then default to hacker.
*/
if (req.user.mentor === true) {
res.status(200).json({
status: 200,
role: "mentor"
})
return;
}

res.status(200).json({
status: 200,
role: "hacker"
})
} catch (error) {
res.status(500).json({ error: (error as Error).message })
}
}
Loading