From c215474e243505fcf1692a91c17acfe960f33af3 Mon Sep 17 00:00:00 2001 From: Raphix Date: Wed, 13 Sep 2023 23:29:37 +0200 Subject: [PATCH] Version 0.9.2c - Fix du Online Viewver --- data/users.json | 38 --------------------- src/modules/sub-auth.js | 6 ++++ src/modules/sub-web.js | 32 +++++++++-------- src/web/public/javascript/__index_script.js | 2 +- 4 files changed, 25 insertions(+), 53 deletions(-) diff --git a/data/users.json b/data/users.json index 7be1e00..bc318f6 100644 --- a/data/users.json +++ b/data/users.json @@ -75,44 +75,6 @@ "token": "b4f1b8cd-2711-48b7-b301-0290f9d9f69b", "admin": false }, - { - "auth": { - "token_type": "Bearer", - "access_token": "l7nUoMgqZN1w3f9SE5iSrEuYedaLZF", - "expires_in": 604800, - "refresh_token": "pHiIXvVPBiRY49lqxZe6SqBqmlxgY4", - "scope": "identify guilds.members.read guilds" - }, - "avatar": null, - "communication_disabled_until": null, - "flags": 0, - "joined_at": "2020-03-06T18:17:58.037000+00:00", - "nick": null, - "pending": false, - "premium_since": null, - "roles": [ - "397725552968204288" - ], - "user": { - "id": "249494159629484033", - "username": "immudelki", - "avatar": "9a0742b8d6a2092a049e207dbc0cdf89", - "discriminator": "0", - "public_flags": 0, - "flags": 0, - "banner": null, - "accent_color": 1123662, - "global_name": "Immudelki", - "avatar_decoration_data": null, - "banner_color": "#11254e" - }, - "mute": false, - "deaf": false, - "bio": "", - "banner": null, - "token": "3b65e082-8a12-4124-9c81-d296b618c68f", - "admin": true - }, { "auth": { "token_type": "Bearer", diff --git a/src/modules/sub-auth.js b/src/modules/sub-auth.js index 59fc6ed..18c493b 100644 --- a/src/modules/sub-auth.js +++ b/src/modules/sub-auth.js @@ -164,6 +164,7 @@ module.exports.getUsersList = function () { } + return userList } @@ -172,6 +173,11 @@ module.exports.getSimpleUser = function (token) { var user = users.get(token) + if(!user) { + + return null + } + return ({"username": user.user.username, "global_name":user.user.global_name, "avatar": user.user.avatar, "id": user.user.id, "admin": user.admin}) } diff --git a/src/modules/sub-web.js b/src/modules/sub-web.js index 033a74c..6edc2de 100644 --- a/src/modules/sub-web.js +++ b/src/modules/sub-web.js @@ -186,9 +186,11 @@ function IOConnection(io) { var utoken = ucookies.token const online_users_data = auth.getSimpleUser(utoken) - - usersOnline.push(online_users_data) - + if(online_users_data) { + usersOnline.push(online_users_data) + + } + alog.log(online_users_data.username + " - Connexion du serveur") } @@ -208,20 +210,22 @@ function IOConnection(io) { var utoken = ucookies.token const online_users_data = auth.getSimpleUser(utoken) - var userIndex = -1 + if(online_users_data) { - for(var user of usersOnline) { - if(user.username == online_users_data.username) { - - userIndex = usersOnline.indexOf(user) - } + var userIndex = -1 + for(var user of usersOnline) { + if(user.username == online_users_data.username) { + + userIndex = usersOnline.indexOf(user) + } + + } + + alog.log(online_users_data.username + " - Deconnexion du serveur") + + usersOnline.splice(userIndex, 1) } - - alog.log(online_users_data.username + " - Deconnexion du serveur") - - usersOnline.splice(userIndex, 1) - } diff --git a/src/web/public/javascript/__index_script.js b/src/web/public/javascript/__index_script.js index e3c0dfc..6a0d369 100644 --- a/src/web/public/javascript/__index_script.js +++ b/src/web/public/javascript/__index_script.js @@ -573,7 +573,7 @@ function loadPlaylist(key, value) { }) playNow.addEventListener("click", () => { - + send("ADD_SONG_NOW", value[add_to.id.replace("_padd", "")]) })