GithubHelp home page GithubHelp logo

znichola / ft_transcendence Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 2.97 MB

The final project of the 42 common core: a website to play pong and chat with friends

Makefile 0.27% Dockerfile 0.29% JavaScript 0.32% TypeScript 98.27% HTML 0.08% CSS 0.18% Shell 0.05% PLpgSQL 0.53%
42lausanne ecole42

ft_transcendence's Issues

conversation api delete

Screen Shot 2023-10-05 at 7 23 54 PM

add the possibility to delete a conversation for either participant:

delte on /conversations/{user1}/{user2}

Style the `/play` page

Do the css and stuff so it looks good,

also think about the options, pause, resume, player controles etc..

Special Pong

a ball has a x% chance to split into 2 (smaller?) balls every time it crosses the middle field. game reset only when all balls disappear (= when scored).
if normal won with 5 points, then special won with 10? 15? 20?

Interface for `User`

This interface should be re structured to fit all the information we want to fetch about a user

Login process with 2fa

How to inform the frontend that tfa is enabled ?
As of now, logging in returns a JSON object with the user login42, and 2fa status (true or false). If it is true, then the user should be asked for his Authenticator code, then a POST request to /tfa/{username}/login should be sent, with a body containing the code as tfaCode (6 characters string, no space)

What to provide to the frontend after a successful login ?
I currently send back the login42 of the logged in user. Please let me know if this work for you, or if you want me to return more/different data

Matchmaking and Game Rooms management

I just wanted to propose a workflow that seem easy enough to me for the implementation of the matchmaking and management of multiple games :

  • All users joining the matchmaking connect to the websocket, and are added to a userlist
  • The server will match the first user in the userlist with the user with the closest rank (we can use cron to do it on a regular interval)
    • A Room is created within the same websocket
    • Both users are added to the room user list as player 1 and player 2
    • Both users are removed from the matchmaking user list
    • People joining as spectator will be added to the room list as spectator and will not be able to play

At this point, we can specify which room we want to emit too and only the users inside it will receive the information

Please let me know if that would work for you, or if you have any suggestion !

Interface for the `GameState`

export type Login42 = string

export type GameMode = "CLASSICAL" | "SPECIAL";

export interface GameState {
  // idk, something about the ball and player positions
}

export interface Game {
  id: number;
  p1: Login42;
  p2: Login42;
  mode: GameMode;
  endGameState: GameState;
  // and some more stufff and things 
}

auth check for page refresh

before redirecting to the auth page on a page refresh we should check if there is a login cookie and use that instead, it would avoid this annoying relog screen on each page refresh

Chatroom name, should be unique

This is to sort of solve the issue of idempotent post, react will by default do compenent rendering twice to help find non pure functions.
Screen Shot 2023-10-12 at 12 30 49 PM

Implementation Pong front+back

TODO:

  • pause if disconnect
  • pause if button pause pressed?
  • wait then timer to start game when all player connected through websocket

Socket issue on tfa login

The following error is logged after doing a tfa login, which completely stops nest

[Nest] 924  - 10/16/2023, 12:34:05 PM   ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'emit')
TypeError: Cannot read properties of undefined (reading 'emit')
    at Object.socketOnTimeout [as timeout] (node:_http_server:767:37)
    at TransformOperationExecutor.transform (/backend/nestjs/node_modules/src/TransformOperationExecutor.ts:207:39)   
    at TransformOperationExecutor.transform (/backend/nestjs/node_modules/src/TransformOperationExecutor.ts:327:31)   
    at TransformOperationExecutor.transform (/backend/nestjs/node_modules/src/TransformOperationExecutor.ts:327:31)   
    at TransformOperationExecutor.transform (/backend/nestjs/node_modules/src/TransformOperationExecutor.ts:327:31)   
    at ClassTransformer.instanceToPlain (/backend/nestjs/node_modules/src/ClassTransformer.ts:25:21)
    at Object.classToPlain (/backend/nestjs/node_modules/src/index.ts:23:27)
    at ClassSerializerInterceptor.transformToPlain (/backend/nestjs/node_modules/@nestjs/common/serializer/class-serializer.interceptor.js:56:37)   
    at ClassSerializerInterceptor.serialize (/backend/nestjs/node_modules/@nestjs/common/serializer/class-serializer.interceptor.js:49:20)

The error could be because the last part of the login has to be done using Swagger as of now, no issue with a login without 2fa at all.
Will have to check again after implementing the login 2fa code to make sure this does not occur at all (otherwise welcome to 0/100)

500 server error when make protected channel

Request body
{
  "ownerLogin42": "test",
  "name": "foobar",
  "status": "PROTECTED",
"password": "fooabr"
}

Response body
{
  "statusCode": 500,
  "message": "Internal server error"
}

Inteface for the `Chatroom` and `DM`

export type Login42 = string;
export type ChatroomStaus = "PUBLIC" | "PRIVATE" | "PROTECTED";
export type ChatroomRole = "OWNER" | "ADMIN" | "MEMBER";
export type ChatroomUserSanctionStatus = "BANNED" | "MUTTED";

export type ChatroomMessages = Message[];
export type DMmessages = Message[];
export type ChatroomMemebers = ChatroomUser[];
export type ChatroomSanctionedUsers = ChatroomSanction[];

export interface DM {
  id: number;
  other: Login42; // omitting the current user, because the query is only made by a user, in the url it's user1
}

export interface Message {
  sender: Login42;
  content: string;
  sentAT: Date; // maybe this is the best way to type a date, string might be better
}

export interface Chatroom {
  id: number;
  name: string;
  owner: Login42;
  status: ChatroomStaus;
}

export interface ChatroomUser {
  user: Login42;
  role: ChatroomRole;
}

export interface ChatroomSanction {
  user: Login42;
  sanction: ChatroomUserSanctionStatus;
  time_left: string | "indefinite";
}

// and of the obligatory and I've missed something so please do modify this

Rename "friends"

the Friends table is used for relationship and should be renamed accordingly

Use HTTPS

Bearer Token Authentication (what we're using) should only be used over HTTPS.
Also, we're transmitting the password for the chatroom over the network so communication should be encrypted.

Backend shit-fine

  • Unify backend and frontend serving points (nginx)
  • Swagger for backend documentation and testing :) jerome says its great

maybe the then is redundent

export const putUserFriendRequest = async (
  current_user: string,
  login42: string,
) => {
  return authApi
    .put<HttpStatusCode>("/user/" + current_user + "/friends/" + login42)
    .then((res) => res.data);
  // .catch((error) => console.log(error.toJSON));
};

the docs for react Query have a section for making axios requests and they don't do the useless then thing

https://tanstack.com/query/v4/docs/react/guides/query-cancellation#using-axios-v0220

to test and if useless remove it fron the Api-axios.tsx file, also this file should have a small letter to start as it's not a react component.

current user card

make it so the currect user card does not have the interaction button and it should also probably be highlighted in some way.

Re sytle the user profile

Additional information needs to be displayed: the win / losses and current elo

Action buttons need to be present for adding friend / message / dule, same as on the player card, this restyle might need to go handin hand with the restyling of the player card in global ranking.

QRCode generation returns file data instead of image

When generating a QR code for the user to scan, the generated QR code is returned as text (this text can be saved to a file to create the working QR Code)
Do you have any ways to use it in React to display the image from its data ? I cannot use the same ReadStream as I did for the user avatar because the QRCode is not locally saved

nest package has `critical` vulnerability!

nest      |
nest      | up to date, audited 799 packages in 4s
nest      |
nest      |
nest      |
nest      | 120 packages are looking for funding
nest      |   run `npm fund` for details
nest      |
nest      | 1 critical severity vulnerability
nest      |
nest      | To address all issues, run:
nest      |   npm audit fix
nest      |
nest      | Run `npm audit` for details.

Global user search name filters incorrectly

The name filtering only displays user whose name start with the searched string, instead of every name containing it (/user endpoint already have this filtering implemented)

Cookie name set in env

Current cookie name is hardcoded as test, probably better to set a name in the .env file !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.