Update server/modules/authentication/discord/authentication.js

cleaner refactoring of authentication logic.

Co-authored-by: Tymoteusz Boba <Tymoteusz.Boba@gmail.com>
pull/6323/head
TomDakan 2 years ago committed by GitHub
parent e76d518041
commit b7189fbf73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 })) {

Loading…
Cancel
Save