fix log color

This commit is contained in:
Lara REALI 2023-06-26 07:26:27 +02:00
parent 49d73b92d3
commit 53106b33bc
3 changed files with 522 additions and 546 deletions

View File

@ -95,8 +95,7 @@ export class AppController {
const user = await this.userService.findOne(req.user.username) const user = await this.userService.findOne(req.user.username)
if (!user) if (!user)
return (0); return (0);
if (user.friends.find(item => item === data.username)) if (user.friends.find(item => item === data.username)) {
{
user.friendRequest = user.friendRequest.filter((item) => item !== data.username); user.friendRequest = user.friendRequest.filter((item) => item !== data.username);
this.userService.save(user); this.userService.save(user);
return (1); return (1);
@ -276,23 +275,20 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('/rank') @Get('/rank')
async getRank(@Request() req) async getRank(@Request() req) {
{
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
return user.rank; return user.rank;
} }
// @UseGuards(JwtAuthGuard) // @UseGuards(JwtAuthGuard)
@Get('/ranking') @Get('/ranking')
async getRanking() async getRanking() {
{
return await this.userService.getRanking(); return await this.userService.getRanking();
} }
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/partyInvite') @Post('/partyInvite')
async partyInvite(@Request() req, @Body() data: any) async partyInvite(@Request() req, @Body() data: any) {
{
//find data.username and add invite to list //find data.username and add invite to list
console.log("data post priv invite=", data); console.log("data post priv invite=", data);
const user = await this.userService.findOne(data.username); const user = await this.userService.findOne(data.username);
@ -306,8 +302,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('/partyInvite') @Get('/partyInvite')
async getPartyInvite(@Request() req, @Body() data: any) async getPartyInvite(@Request() req, @Body() data: any) {
{
//find data.username and add invite to list //find data.username and add invite to list
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
user.partyInvite = user.partyInvite || []; user.partyInvite = user.partyInvite || [];
@ -319,8 +314,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/deleteInvite') @Post('/deleteInvite')
async deleteInvite(@Request() req, @Body() data: any) async deleteInvite(@Request() req, @Body() data: any) {
{
console.log("delete invite user= ", data.username) console.log("delete invite user= ", data.username)
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
@ -334,8 +328,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/history') @Post('/history')
async getHistory(@Body() data: any) async getHistory(@Body() data: any) {
{
// const user = await this.userService.findOne(req.user.username); // const user = await this.userService.findOne(req.user.username);
// return user.rank; // return user.rank;
return await this.userService.getHistory(data.username); return await this.userService.getHistory(data.username);
@ -388,8 +381,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Get('/2fa') @Get('/2fa')
async get2fa(@Request() req) async get2fa(@Request() req) {
{
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
return user.otp_enabled; return user.otp_enabled;
} }
@ -397,8 +389,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/otp') @Post('/otp')
async createOTP(@Request() req) async createOTP(@Request() req) {
{
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
// const user2 = await this.userService.findOne(req.user.username); // const user2 = await this.userService.findOne(req.user.username);
const res = await generateOTP(user); const res = await generateOTP(user);
@ -409,8 +400,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/verifyOtp') @Post('/verifyOtp')
async verifyOTP(@Request() req, @Body() data: any) async verifyOTP(@Request() req, @Body() data: any) {
{
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
const res = await VerifyOTP(user, data.token) const res = await VerifyOTP(user, data.token)
console.log('token in verify=', data.token) console.log('token in verify=', data.token)
@ -421,8 +411,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/validateOtp') @Post('/validateOtp')
async validateOTP(@Request() req, @Body() data: any) async validateOTP(@Request() req, @Body() data: any) {
{
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
const res = await ValidateOTP(user, data.token) const res = await ValidateOTP(user, data.token)
// await this.userService.save(user); // await this.userService.save(user);
@ -431,8 +420,7 @@ export class AppController {
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard)
@Post('/deleteOtp') @Post('/deleteOtp')
async deleteOTP(@Request() req, @Body() data: any) async deleteOTP(@Request() req, @Body() data: any) {
{
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
user.otp_verified = false; user.otp_verified = false;
await this.userService.save(user); await this.userService.save(user);
@ -466,7 +454,9 @@ export class AppController {
async addSession(@Request() req) { async addSession(@Request() req) {
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
user.sessionNumber++ ; user.sessionNumber += 1;
if (user.status !== 2) //super
user.status = 1;
console.log("addSession sessionNUmber :", user.sessionNumber); console.log("addSession sessionNUmber :", user.sessionNumber);
await this.userService.save(user); await this.userService.save(user);

View File

@ -74,14 +74,10 @@ export class loginClass {
friends: null, friends: null,
blocked: null, blocked: null,
photo: null, photo: null,
sessionNumber: 1, sessionNumber: 0,
}; };
await this.usersService.create(user); await this.usersService.create(user);
} }
// if (user.status !== 2) //super
// user.status = 1;
// user.sessionNumber++;
console.log(user.sessionNumber);
const myJSON = JSON.stringify(user); const myJSON = JSON.stringify(user);
console.log(`in login42 user= ${myJSON}`) console.log(`in login42 user= ${myJSON}`)

View File

@ -36,18 +36,7 @@ function AnimatedRoute() {
} }
}; };
window.addEventListener('beforeunload', handleBeforeUnload);
return () => {
window.removeEventListener('beforeunload', handleBeforeUnload);
};
}, []);
useEffect(() => {
const handleLoad = async () => { const handleLoad = async () => {
console.log('Page loaded');
console.log("je suis a addSession");
if (!localStorage.getItem('token')) if (!localStorage.getItem('token'))
return; return;
try { try {
@ -57,9 +46,10 @@ function AnimatedRoute() {
} }
}; };
window.addEventListener('load', handleLoad); handleLoad();
window.addEventListener('beforeunload', handleBeforeUnload);
return () => { return () => {
window.removeEventListener('load', handleLoad); window.removeEventListener('beforeunload', handleBeforeUnload);
}; };
}, []); }, []);