znichola / ft_transcendence Goto Github PK
View Code? Open in Web Editor NEWThe final project of the 42 common core: a website to play pong and chat with friends
The final project of the 42 common core: a website to play pong and chat with friends
Do the css and stuff so it looks good,
also think about the options, pause, resume, player controles etc..
This menue needs to be created with all the apropriate options:
a list of users
a list to add user to the channel
user actions, toggle status admin/memebr, kick, ban mute, mute for time period
This has been super annoying to try pinpoint where the-f it's comming from. But I've got a pretty nice lead here:
https://tanstack.com/query/v4/docs/react/guides/migrating-to-react-query-4#setlogger-is-removed
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?
This interface should be re structured to fit all the information we want to fetch about a user
children?: JSX.Element[];
// to
children: ReactNode;
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
I just wanted to propose a workflow that seem easy enough to me for the implementation of the matchmaking and management of multiple games :
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 !
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
}
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
When i'm on the profile page and i reload, i'm taken back to the login page.
I chose to hide the PRIVATE chatrooms, but we need to see them if we're member of the chatroom, right?
TODO:
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)
Request body
{
"ownerLogin42": "test",
"name": "foobar",
"status": "PROTECTED",
"password": "fooabr"
}
Response body
{
"statusCode": 500,
"message": "Internal server error"
}
https://stackoverflow.com/questions/49967779/axios-handling-errors
basically the idea is to set our own callback function that handles, the http errors, we would just re throw the errors that are not 401
and for 401
an invalidation of the authprovider, this will automatically redirect to the login page.
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
cards should be brought in line with the style of the side menu and chat page
the Friends table is used for relationship and should be renamed accordingly
if image loading fails, or the user does not have an image set, give a default image.
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.
it always seems to return
{
"message": "Cannot change role of owner",
"error": "Forbidden",
"statusCode": 403
}
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.
make it so the currect user card does not have the interaction button and it should also probably be highlighted in some way.
Instead of calling getCurrentUser allover the place, use the authContext
to get the current user, then figure out how to get it so the current user gets updated, when there is an error.
This error keeps printing in the console, should be found and squashed, can't submit with errors being printed
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.
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
Is this something we want to do? Would it make the project better / would bootup times be faster, is it cleaner etc..
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.
The menu box we have for the chat should be made properly reusable and so used for the dm, chatroom, and ranking search.
This issue ties in with #8 because it's currently a pain to pass proprs to the delete function.
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)
Current cookie name is hardcoded as test, probably better to set a name in the .env file !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.