From 5284c1fadd7d4d771cfa22212adafc77733b5d29 Mon Sep 17 00:00:00 2001 From: Raphix Date: Tue, 22 Aug 2023 18:38:55 +0200 Subject: [PATCH] Versiion 0.2.3 - Ajout Handle Case Discriminator --- data/users.json | 4 ++-- package-lock.json | 2 +- package.json | 2 +- src/modules/sub-auth.js | 9 +++++++-- src/web/routes/internal.js | 16 +++++++++++++--- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/data/users.json b/data/users.json index 24932cd..075dda0 100644 --- a/data/users.json +++ b/data/users.json @@ -5,7 +5,7 @@ "access_token": "jY17lCWaOpTdPQCnz50kfNm7ABpsGz", "expires_in": 604800, "refresh_token": "3TronknZ7j5kVSDBjI3OechmCYF8ck", - "scope": "guilds guilds.members.read identify" + "scope": "identify guilds guilds.members.read" }, "avatar": null, "communication_disabled_until": null, @@ -34,6 +34,6 @@ "deaf": false, "bio": "", "banner": null, - "token": "289373d4-8733-484b-b674-2230e0afc6ae" + "token": "7149b971-4595-496c-a541-4c687a37ffd6" } ] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 682fef0..a222773 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "subsonics-web", - "version": "0.2.2", + "version": "0.2.3", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 635e724..f84a7b2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "subsonics-web", "author": "Raphix", - "version": "0.2.2", + "version": "0.2.3", "nodemonConfig": { "ext": "js, html", "ignore": [ diff --git a/src/modules/sub-auth.js b/src/modules/sub-auth.js index 4870741..f386630 100644 --- a/src/modules/sub-auth.js +++ b/src/modules/sub-auth.js @@ -40,7 +40,7 @@ module.exports.getDiscordUser = function (code, session) { return new Promise((resolve, reject) => { - alog.log("Récupération de l'autorisation de récupération des informations de l'utilisateur associé à la session : " + session + "[ETAPE 2]") + alog.log("Récupération de l'autorisation de récupération des informations de l'utilisateur associé à la session : " + session + " [ETAPE 2]") var link = "https://subsonics.raphix.fr" @@ -64,7 +64,7 @@ module.exports.getDiscordUser = function (code, session) { }, body : params }).then(resp1 => resp1.json()).then(authorizationKey => { - alog.log("Récupération des informations de l'utilisateur associé à l'autorisation : '" + authorizationKey.access_token + "' et associé à la session : " + session + "[ETAPE 3]") + alog.log("Récupération des informations de l'utilisateur associé à l'autorisation : '" + authorizationKey.access_token + "' et associé à la session : " + session + " [ETAPE 3]") fetch('https://discord.com/api/users/@me/guilds/137291455336022018/member', { headers: { @@ -74,6 +74,11 @@ module.exports.getDiscordUser = function (code, session) { var user = {} + if(userInfo.user.discriminator) { + reject("MIGRATE_ACCOUNT_ONLY") + + } + user.auth = authorizationKey Object.assign(user, userInfo) diff --git a/src/web/routes/internal.js b/src/web/routes/internal.js index bfea327..8bc3a6c 100644 --- a/src/web/routes/internal.js +++ b/src/web/routes/internal.js @@ -19,8 +19,8 @@ router.get('/redirect', function(req, res, next) { if(req.query.code) { - alog.step.init("get_discord_info_" + req.cookies.session , "Récupération des informations de l'utilisateur associé à l'autorisation : '" + req.cookies.sessionn + "'") - + alog.step.init("get_discord_info_" + req.cookies.session , "Récupération des informations de l'utilisateur associé à l'autorisation : '" + req.cookies.session + "'") + const user = auth.getDiscordUser(req.query.code, req.cookies.session) user.then(data => { @@ -43,7 +43,17 @@ router.get('/redirect', function(req, res, next) { alog.step.error("get_discord_info_" + req.cookies.session) console.log(error) - res.redirect('/login?error=CANCEL_LOGIN') + + if(error == "MIGRATE_ACCOUNT_ONLY") { + + res.redirect('/login?error=MIGRATE_ACCOUNT_ONLY') + + } else { + + res.redirect('/login?error=CANCEL_LOGIN') + + } + })