Added package.json. Fixed bug in authentication.js

pull/6323/head
TomDakan 2 years ago
parent 1b66420689
commit e76d518041

@ -6,12 +6,12 @@
const DiscordStrategy = require('passport-discord').Strategy
const _ = require('lodash')
const DiscordOauth2 = require('discord-oauth2')
const DiscordOauth2 = require('./node_modules/discord-oauth2/index.js') //I don't remember why I
// Checks for the existence of all of the configured role IDs in the member's guild IDs.
// Checks for the existence of all of the required role IDs in the member's guild role IDs.
function hasRoles(memberRoles, authRoles) {
if (memberRoles.every(value => {
return authRoles.includes(value)
if (authRoles.every(value => {
return memberRoles.includes(value)
})) {
return true
} else {
@ -34,7 +34,7 @@ module.exports = {
if (conf.roles) {
const discord = new DiscordOauth2()
const memberRoles = await discord.getGuildMember(accessToken, conf.guildId)
if (!hasRoles(memberRoles.roles, conf.roles)) {
if (!hasRoles(memberRoles.roles, conf.roles.split())) {
throw new WIKI.Error.AuthLoginFailed()
}
} else if (conf.guildId && !_.some(profile.guilds, { id: conf.guildId })) {

@ -0,0 +1,22 @@
{
"name": "wikijs-discord-oauth2",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "wikijs-discord-oauth2",
"version": "1.0.0",
"license": "AGPL-3.0-or-later",
"dependencies": {
"discord-oauth2": "^2.11.0"
},
"devDependencies": {}
},
"node_modules/discord-oauth2": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/discord-oauth2/-/discord-oauth2-2.11.0.tgz",
"integrity": "sha512-pIbgXm498f7vqNd8/7JwoLd36YMFOFASSJdqyCGdwQpaG7ULHu9nLyifpVXI1b88xvNLqQwqugS8jxkn8Ypd1Q=="
}
}
}

@ -0,0 +1,19 @@
{
"name": "wikijs-discord-oauth2",
"version": "1.0.0",
"description": "Supports using Discord as a SSO source, and allows the administrator to configure discord groups that are required for authentication.",
"main": "authentication.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"wikijs",
"discord",
"sso"
],
"author": "Tom Dakan",
"license": "AGPL-3.0-or-later",
"dependencies": {
"discord-oauth2": "^2.11.0"
}
}
Loading…
Cancel
Save