-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added JWT on top of Firebase-Admin (#178)
* Made error case for email in use display correctly in front end * Made error case for email in use display correctly in front end (#158) * Cleaned up useEffect function #159 * Added testing pipeline (#175) * Create main.yml * Update main.yml * Update _layout.tsx * Update main.yml * Update socketio.test.ts * Update socketio.test.ts * Update _layout.tsx * User Context and User Type created and wrapped chat screen (#131) * added user context * Added userID and displayName * moved user and display name generation into UserProvider * Improved UserContext implementation Amongst these changes, the user type on the frontend has been edited in order to prevent hidden functions that would pull information into the UserContext from other contexts. The message type was also modified to keep a new author section with a displayName attribute. An issue should be created for a socket API endpoint for grabbing the displayName, and one to set it in a connectedUser document in the databse. * updated package lock --------- Co-authored-by: h1divp <[email protected]> * Set up Firebase-Admin in adminInit.ts (#155) * new branch + function fix * small bug fixes * fixes pt2 * JWT WIP * new branch + function fix * small bug fixes * fixes pt2 * JWT WIP * new branch + function fix * small bug fixes * fixes pt2 * JWT WIP * new branch + function fix * small bug fixes * added passport * started auth + admin sdk * removed passport * added private key to gitignore * Delete server/private_keys/private.json --------- Co-authored-by: AlexanderWangY <[email protected]> * Refactored most of the actions (#156) * new branch + function fix * small bug fixes * fixes pt2 * JWT WIP * new branch + function fix * small bug fixes * fixes pt2 * JWT WIP * new branch + function fix * small bug fixes * fixes pt2 * JWT WIP * new branch + function fix * small bug fixes * added passport * started auth + admin sdk * removed passport * added private key to gitignore * Delete server/private_keys/private.json * initializing firestore in admin * finished most of action refactoring * Made error case for email in use display correctly in front end (#158) * changed getConnectedUsers to admin * migrated to firebase-admin --------- Co-authored-by: AlexanderWangY <[email protected]> Co-authored-by: Mohammed Ali <[email protected]> * added middleware --------- Co-authored-by: Phantom0110 <[email protected]> Co-authored-by: Mohammed Ali <[email protected]> Co-authored-by: AaronGibson2 <[email protected]> Co-authored-by: h1divp <[email protected]> Co-authored-by: AlexanderWangY <[email protected]>
- Loading branch information
1 parent
386b646
commit 9263c96
Showing
14 changed files
with
229 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Unit Tests | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [21.x] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
working-directory: server/ | ||
|
||
- name: Set up environment variables | ||
env: | ||
API_KEY: ${{ secrets.API_KEY }} | ||
AUTH_DOMAIN: ${{ secrets.AUTH_DOMAIN }} | ||
PROJECT_ID: ${{ secrets.PROJECT_ID }} | ||
STORAGE_BUCKET: ${{ secrets.STORAGE_BUCKET }} | ||
MESSAGING_SENDER_ID: ${{ secrets.MESSAGING_SENDER_ID }} | ||
APP_ID: ${{ secrets.APP_ID }} | ||
MESSAGE_OUTREACH_RADIUS: ${{ secrets.MESSAGE_OUTREACH_RADIUS }} | ||
EXPRESS_PORT: ${{ secrets.EXPRESS_PORT }} | ||
SOCKET_PORT: ${{ secrets.SOCKET_PORT }} | ||
SOCKET_TEST_CLIENT_PORT: ${{ secrets.SOCKET_TEST_CLIENT_PORT }} | ||
run: | | ||
echo "API_KEY=${API_KEY}" >> .env | ||
echo "AUTH_DOMAIN=${AUTH_DOMAIN}" >> .env | ||
echo "PROJECT_ID=${PROJECT_ID}" >> .env | ||
echo "STORAGE_BUCKET=${STORAGE_BUCKET}" >> .env | ||
echo "MESSAGING_SENDER_ID=${MESSAGING_SENDER_ID}" >> .env | ||
echo "APP_ID=${APP_ID}" >> .env | ||
echo "message_outreach_radius=${MESSAGE_OUTREACH_RADIUS}" >> .env | ||
echo "express_port=${EXPRESS_PORT}" >> .env | ||
echo "socket_port=${SOCKET_PORT}" >> .env | ||
echo "socket_test_client_port=${SOCKET_TEST_CLIENT_PORT}" >> .env | ||
working-directory: server/ | ||
|
||
- name: Compile TypeScript files | ||
run: npx tsc | ||
working-directory: server/ | ||
|
||
- name: Start index.ts in background | ||
run: npm start & | ||
working-directory: server/ | ||
|
||
- name: Wait for server to start | ||
run: sleep 5 # Adjust sleep time as needed to allow the server to start | ||
timeout-minutes: 1 | ||
|
||
- name: Run tests | ||
run: npm test | ||
working-directory: server/ |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { createContext, useContext } from 'react'; | ||
import { UserType } from '../types/User'; | ||
import { useState } from 'react'; | ||
|
||
const UserContext = createContext<UserType | null>(null); | ||
|
||
export const useUser = () => { | ||
return useContext(UserContext); | ||
} | ||
|
||
export const UserProvider = ({ children }: {children: React.ReactNode}) => { | ||
const [user, setUser] = useState<UserType>({ | ||
displayName: "DefaultDisplayName", | ||
userIcon: { | ||
imagePath: "DefaultImagePath", | ||
colorHex: "#fff" | ||
}, | ||
}); | ||
|
||
return ( | ||
<UserContext.Provider value={user}> | ||
{children} | ||
</UserContext.Provider> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface UserType { | ||
displayName: string | ||
userIcon?: { | ||
imagePath: string | ||
colorHex: string | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export type MessageType = { | ||
messageContent: string; | ||
author: string; | ||
msgID: string; | ||
}; | ||
|
||
export type UserType = { | ||
userID: string; | ||
displayName: string; | ||
pfp: string; | ||
}; |
Oops, something went wrong.