fix log color
This commit is contained in:
parent
49d73b92d3
commit
53106b33bc
@ -10,7 +10,7 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
import { Controller, Request, Req, Get, Post, UseGuards, Redirect, Res, Body, UploadedFile, UseInterceptors} from '@nestjs/common';
|
||||
import { Controller, Request, Req, Get, Post, UseGuards, Redirect, Res, Body, UploadedFile, UseInterceptors } from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { JwtAuthGuard } from './auth/jwt-auth.guard';
|
||||
import { AuthService } from './auth/auth.service';
|
||||
@ -44,17 +44,17 @@ export class AppController {
|
||||
constructor(private authService: AuthService,
|
||||
private loginClass: loginClass,
|
||||
private chatService: ChatService,
|
||||
private userService: UsersService, ) {}
|
||||
private userService: UsersService,) { }
|
||||
|
||||
kFactor = 36;
|
||||
scaleFactor = 400;
|
||||
|
||||
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
// User
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
// User
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('/profile')
|
||||
@ -68,14 +68,14 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/user')
|
||||
async getUser( @Body() data: any) {
|
||||
async getUser(@Body() data: any) {
|
||||
console.log(`usernamewwww= ${data.username}`)
|
||||
return await this.userService.findOne(data.username);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('/users')
|
||||
async getUsers( @Body() data: any) {
|
||||
async getUsers(@Body() data: any) {
|
||||
console.log(`usernamewwww= ${data.username}`)
|
||||
return await this.userService.findAll();
|
||||
}
|
||||
@ -95,8 +95,7 @@ export class AppController {
|
||||
const user = await this.userService.findOne(req.user.username)
|
||||
if (!user)
|
||||
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);
|
||||
this.userService.save(user);
|
||||
return (1);
|
||||
@ -220,11 +219,11 @@ export class AppController {
|
||||
// return await this.userService.save(user);
|
||||
}
|
||||
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
// Pong
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
// Pong
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/win')
|
||||
@ -276,23 +275,20 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('/rank')
|
||||
async getRank(@Request() req)
|
||||
{
|
||||
async getRank(@Request() req) {
|
||||
const user = await this.userService.findOne(req.user.username);
|
||||
return user.rank;
|
||||
}
|
||||
|
||||
// @UseGuards(JwtAuthGuard)
|
||||
// @UseGuards(JwtAuthGuard)
|
||||
@Get('/ranking')
|
||||
async getRanking()
|
||||
{
|
||||
async getRanking() {
|
||||
return await this.userService.getRanking();
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/partyInvite')
|
||||
async partyInvite(@Request() req, @Body() data: any)
|
||||
{
|
||||
async partyInvite(@Request() req, @Body() data: any) {
|
||||
//find data.username and add invite to list
|
||||
console.log("data post priv invite=", data);
|
||||
const user = await this.userService.findOne(data.username);
|
||||
@ -306,8 +302,7 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('/partyInvite')
|
||||
async getPartyInvite(@Request() req, @Body() data: any)
|
||||
{
|
||||
async getPartyInvite(@Request() req, @Body() data: any) {
|
||||
//find data.username and add invite to list
|
||||
const user = await this.userService.findOne(req.user.username);
|
||||
user.partyInvite = user.partyInvite || [];
|
||||
@ -319,8 +314,7 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/deleteInvite')
|
||||
async deleteInvite(@Request() req, @Body() data: any)
|
||||
{
|
||||
async deleteInvite(@Request() req, @Body() data: any) {
|
||||
console.log("delete invite user= ", data.username)
|
||||
const user = await this.userService.findOne(req.user.username);
|
||||
|
||||
@ -334,8 +328,7 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/history')
|
||||
async getHistory(@Body() data: any)
|
||||
{
|
||||
async getHistory(@Body() data: any) {
|
||||
// const user = await this.userService.findOne(req.user.username);
|
||||
// return user.rank;
|
||||
return await this.userService.getHistory(data.username);
|
||||
@ -355,20 +348,20 @@ export class AppController {
|
||||
}
|
||||
|
||||
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
// Auth
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
// Auth
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
|
||||
// import { Prisma } from "@prisma/client";
|
||||
// import { Request, Response, NextFunction } from "express";
|
||||
// import { prisma } from "../server";
|
||||
// import { Prisma } from "@prisma/client";
|
||||
// import { Request, Response, NextFunction } from "express";
|
||||
// import { prisma } from "../server";
|
||||
|
||||
|
||||
|
||||
@Redirect('http://' + process.env.BASE_URL + '/token', 302)
|
||||
@Get('auth/login')
|
||||
@Redirect('http://' + process.env.BASE_URL + '/token', 302)
|
||||
@Get('auth/login')
|
||||
async login2(@Req() request: Request) {
|
||||
const url = request.url;
|
||||
const user = await this.loginClass.Login42(url);
|
||||
@ -388,8 +381,7 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('/2fa')
|
||||
async get2fa(@Request() req)
|
||||
{
|
||||
async get2fa(@Request() req) {
|
||||
const user = await this.userService.findOne(req.user.username);
|
||||
return user.otp_enabled;
|
||||
}
|
||||
@ -397,8 +389,7 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/otp')
|
||||
async createOTP(@Request() req)
|
||||
{
|
||||
async createOTP(@Request() req) {
|
||||
const user = await this.userService.findOne(req.user.username);
|
||||
// const user2 = await this.userService.findOne(req.user.username);
|
||||
const res = await generateOTP(user);
|
||||
@ -409,8 +400,7 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@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 res = await VerifyOTP(user, data.token)
|
||||
console.log('token in verify=', data.token)
|
||||
@ -421,8 +411,7 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@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 res = await ValidateOTP(user, data.token)
|
||||
// await this.userService.save(user);
|
||||
@ -431,8 +420,7 @@ export class AppController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@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);
|
||||
user.otp_verified = false;
|
||||
await this.userService.save(user);
|
||||
@ -441,21 +429,21 @@ export class AppController {
|
||||
// return res
|
||||
}
|
||||
|
||||
// @UseGuards(JwtAuthGuard)
|
||||
// @Get('/QRcode')
|
||||
// async createQrCode(@Request() req)
|
||||
// {
|
||||
// return (await generateQRcode(req));
|
||||
// }
|
||||
// @UseGuards(JwtAuthGuard)
|
||||
// @Get('/QRcode')
|
||||
// async createQrCode(@Request() req)
|
||||
// {
|
||||
// return (await generateQRcode(req));
|
||||
// }
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/quit')
|
||||
async setOffline(@Request() req) {
|
||||
const user = await this.userService.findOne(req.user.username);
|
||||
user.sessionNumber-- ;
|
||||
user.sessionNumber--;
|
||||
if (!user.sessionNumber)
|
||||
user.status = 0;
|
||||
console.log("quit sessionNUmber :",user.sessionNumber);
|
||||
console.log("quit sessionNUmber :", user.sessionNumber);
|
||||
|
||||
await this.userService.save(user);
|
||||
console.log("User quit");
|
||||
@ -466,17 +454,19 @@ export class AppController {
|
||||
async addSession(@Request() req) {
|
||||
|
||||
const user = await this.userService.findOne(req.user.username);
|
||||
user.sessionNumber++ ;
|
||||
console.log("addSession sessionNUmber :",user.sessionNumber);
|
||||
user.sessionNumber += 1;
|
||||
if (user.status !== 2) //super
|
||||
user.status = 1;
|
||||
console.log("addSession sessionNUmber :", user.sessionNumber);
|
||||
|
||||
await this.userService.save(user);
|
||||
}
|
||||
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
// Chat
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
// Chat
|
||||
//========================================================================================================
|
||||
//========================================================================================================
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('/conv')
|
||||
@ -588,7 +578,7 @@ export class AppController {
|
||||
@Post('/ban')
|
||||
async banUser(@Body() data: any) {
|
||||
if (!data.username)
|
||||
return ;
|
||||
return;
|
||||
return await this.chatService.banUser(data.convId, data.username)
|
||||
}
|
||||
|
||||
@ -596,7 +586,7 @@ export class AppController {
|
||||
@Post('/admin')
|
||||
async setAdmin(@Body() data: any) {
|
||||
if (!data.username)
|
||||
return ;
|
||||
return;
|
||||
return await this.chatService.setAdmin(data.convId, data.username)
|
||||
}
|
||||
|
||||
@ -604,7 +594,7 @@ export class AppController {
|
||||
@Post('/mute')
|
||||
async muteUser(@Body() data: any) {
|
||||
if (!data.username)
|
||||
return ;
|
||||
return;
|
||||
return await this.chatService.muteUser(data.convId, data.username, data.time)
|
||||
}
|
||||
|
||||
|
||||
@ -74,14 +74,10 @@ export class loginClass {
|
||||
friends: null,
|
||||
blocked: null,
|
||||
photo: null,
|
||||
sessionNumber: 1,
|
||||
sessionNumber: 0,
|
||||
};
|
||||
await this.usersService.create(user);
|
||||
}
|
||||
// if (user.status !== 2) //super
|
||||
// user.status = 1;
|
||||
// user.sessionNumber++;
|
||||
console.log(user.sessionNumber);
|
||||
const myJSON = JSON.stringify(user);
|
||||
console.log(`in login42 user= ${myJSON}`)
|
||||
|
||||
|
||||
@ -36,18 +36,7 @@ function AnimatedRoute() {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
window.addEventListener('beforeunload', handleBeforeUnload);
|
||||
return () => {
|
||||
window.removeEventListener('beforeunload', handleBeforeUnload);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const handleLoad = async () => {
|
||||
console.log('Page loaded');
|
||||
console.log("je suis a addSession");
|
||||
if (!localStorage.getItem('token'))
|
||||
return;
|
||||
try {
|
||||
@ -57,9 +46,10 @@ function AnimatedRoute() {
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('load', handleLoad);
|
||||
handleLoad();
|
||||
window.addEventListener('beforeunload', handleBeforeUnload);
|
||||
return () => {
|
||||
window.removeEventListener('load', handleLoad);
|
||||
window.removeEventListener('beforeunload', handleBeforeUnload);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user