Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websockets + Google Authorization #55

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Websockets + Google Authorization #55

wants to merge 20 commits into from

Conversation

watawada
Copy link
Collaborator

@watawada watawada commented Jan 5, 2025

Issue #28

  • Modified passport file and user schema to save user's ID token once authenticated.
  • Added get-token route in auth.ts to send user's ID token.
  • In bin/www.ts, added socket middleware to verify the user's ID token using the OAuth2 client. If the user is properly authenticated with a valid token, then save the user's user_id in the socket object, which I've extended to have a user field, and call next to listen to the socket server.
  • In socket.ts on the client side, added a get token function to retrieve user's token from the backend. If the response to retrieve the token fails (user is not authenticated through Google), then redirect to login page. Added createSocket function that creates the socket server with an 'auth' header for the ID token. If the get token function threw an error, then the createSocket function will not create the server.
  • In messages page, modified code to use the createSocket function to create the socket.

crebollarramirez and others added 17 commits December 18, 2024 20:31
Initialized socket server, allowed messages to be broadcast/emitted to different rooms (this system will be replaced with UUIDs), stored chat history using mongoDB
…les to help functionality and interactivity. Also have added dummy data to test the messaging UI.
Changed message schema and corresponding frotnend and backend pages.
Implemented user messaging to the hardcoded bots.
Updated the time displayed on message and added bot response.
Allowed socket to accept an authentication token. If the token is not valid or doesn't exist (user does not authenticate through Google), then the websocket connection will not be established.
Made redirection to login page if trying to access messages but not logged in. Added code to passport.ts to update the user's ID token whenever they log in.
Added comments
@watawada watawada linked an issue Jan 5, 2025 that may be closed by this pull request
@crebollarramirez crebollarramirez self-requested a review January 8, 2025 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup WebSocket for Messaging Feature
2 participants