Merge remote-tracking branch 'origin/phoenix' into reborn
This commit is contained in:
commit
0d80c118b4
@ -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);
|
||||
@ -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)
|
||||
@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);
|
||||
@ -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);
|
||||
@ -455,6 +443,8 @@ export class AppController {
|
||||
user.sessionNumber--;
|
||||
if (!user.sessionNumber)
|
||||
user.status = 0;
|
||||
console.log("quit sessionNUmber :", user.sessionNumber);
|
||||
|
||||
await this.userService.save(user);
|
||||
console.log("User quit");
|
||||
}
|
||||
@ -464,7 +454,11 @@ export class AppController {
|
||||
async addSession(@Request() req) {
|
||||
|
||||
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);
|
||||
|
||||
await this.userService.save(user);
|
||||
}
|
||||
|
||||
|
||||
@ -78,10 +78,6 @@ export class loginClass {
|
||||
};
|
||||
await this.usersService.create(user);
|
||||
}
|
||||
// if (user.status !== 2 || user.status === 0) //super
|
||||
// user.status = 1;
|
||||
// user.sessionNumber++;
|
||||
// console.log(`in login42 user= ${user}`)
|
||||
const myJSON = JSON.stringify(user);
|
||||
console.log(`in login42 user= ${myJSON}`)
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ export class UsersService {
|
||||
|
||||
async getFriends(username: string) {
|
||||
const user = await this.findOne(username)
|
||||
let friendsTab = user.friends
|
||||
let friendsTab = user.friends || []
|
||||
console.log(friendsTab)
|
||||
// friendsTab = ['apommier', 'syd']
|
||||
const friends = await this.userRepository.query("SELECT * FROM \"User\" WHERE username = ANY ($1);", [friendsTab]);
|
||||
|
||||
@ -16,6 +16,7 @@ export interface User {
|
||||
partyInvite: Record<string, string>[];
|
||||
friends: string[];
|
||||
blocked: string[];
|
||||
sessionNumber: number;
|
||||
}
|
||||
|
||||
export interface Conv {
|
||||
|
||||
@ -36,16 +36,25 @@ function AnimatedRoute () {
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('beforeunload', handleBeforeUnload);
|
||||
const handleLoad = async () => {
|
||||
if (!localStorage.getItem('token'))
|
||||
return;
|
||||
try {
|
||||
await api.post("/addSession");
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
};
|
||||
|
||||
handleLoad();
|
||||
window.addEventListener('beforeunload', handleBeforeUnload);
|
||||
return () => {
|
||||
window.removeEventListener('beforeunload', handleBeforeUnload);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const location = useLocation();
|
||||
if (!localStorage.getItem('token'))
|
||||
{
|
||||
if (!localStorage.getItem('token')) {
|
||||
return (
|
||||
<AnimatePresence>
|
||||
<Routes location={location} key={location.pathname}>
|
||||
|
||||
@ -79,10 +79,6 @@ const GameModal = ({ handleClose }: ModalGame) => {
|
||||
path += 'superpower=true&';
|
||||
}
|
||||
|
||||
const obstacleCheckbox = document.querySelector<HTMLInputElement>('input[value="obstacle"]');
|
||||
if (obstacleCheckbox && obstacleCheckbox.checked) {
|
||||
path += 'obstacle=true&';
|
||||
}
|
||||
|
||||
const speedCheckbox = document.querySelector<HTMLInputElement>('input[value="speed"]');
|
||||
if (speedCheckbox && speedCheckbox.checked) {
|
||||
@ -132,10 +128,9 @@ const GameModal = ({ handleClose }: ModalGame) => {
|
||||
{/* <button onClick={handleButtonClick}>Draw on Canvas</button> */}
|
||||
<div className='checkbox'>
|
||||
<p><input type="checkbox" value="superpower"/> Super Power </p>
|
||||
<p><input type="checkbox" value="obstacle"/> Obstacle </p>
|
||||
<p><input type="checkbox" value="speed"/> Faster and Faster </p>
|
||||
</div>
|
||||
<button className="submit" onClick={handleButtonClick} >Play</button>
|
||||
<button className="playInvite" onClick={handleButtonClick} >Play</button>
|
||||
{/* <button className="submit" onClick={handleClose}>Cancel</button> */}
|
||||
</div>
|
||||
|
||||
|
||||
@ -66,6 +66,8 @@ export default function Friend({currentUser}: UserProps)
|
||||
function getStatus(friend: User)
|
||||
{
|
||||
let status = friend.status
|
||||
let session =friend.sessionNumber
|
||||
console.log(`session= ${session}`)
|
||||
console.log(`status= ${status}`)
|
||||
let statusColor;
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ export default function Friend({currentUser}: UserProps)
|
||||
}
|
||||
|
||||
return (
|
||||
<UserChat>
|
||||
<UserChat className="centermargin">
|
||||
{profilePicture ? (
|
||||
<img className="pic-user" src={`data:image/jpeg;base64,${profilePicture}`} />
|
||||
) : (
|
||||
|
||||
@ -222,6 +222,16 @@ p {
|
||||
height: 25px;
|
||||
}
|
||||
|
||||
.playInvite{
|
||||
margin: 5%;
|
||||
color: ghostwhite;
|
||||
outline: 0;
|
||||
border-radius: 100px;
|
||||
padding: 3%;
|
||||
background-image: linear-gradient(90deg, #5843e4, #5a0760);
|
||||
width: 42%;
|
||||
font-size: x-large;
|
||||
}
|
||||
.darkSubmit{
|
||||
display: inline-block;
|
||||
color: white;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user