From b7189fbf7380ff9c257fb97cef00f03a785e3680 Mon Sep 17 00:00:00 2001 From: TomDakan Date: Mon, 25 Sep 2023 14:56:54 -0700 Subject: [PATCH] Update server/modules/authentication/discord/authentication.js cleaner refactoring of authentication logic. Co-authored-by: Tymoteusz Boba --- server/modules/authentication/discord/authentication.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/modules/authentication/discord/authentication.js b/server/modules/authentication/discord/authentication.js index 67c079ca..3c0af63a 100644 --- a/server/modules/authentication/discord/authentication.js +++ b/server/modules/authentication/discord/authentication.js @@ -34,7 +34,9 @@ module.exports = { if (conf.roles) { const discord = new DiscordOauth2() const memberRoles = await discord.getGuildMember(accessToken, conf.guildId) - if (!hasRoles(memberRoles.roles, conf.roles.split())) { + const authRoles = conf.roles.split(); + const { roles } = await discord.getGuildMember(accessToken, conf.guildId); + if (authRoles.every(role => roles.includes(role)) throw new WIKI.Error.AuthLoginFailed() } } else if (conf.guildId && !_.some(profile.guilds, { id: conf.guildId })) {