Update .gitignore and add new dependencies and routes
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -3,13 +3,13 @@ const DiscordStrategy = require('passport-discord').Strategy;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const setupFilePath = path.join('setup.json');
|
||||
const setupFilePath = path.join(__dirname, '../data', 'setup.json');
|
||||
const setupData = JSON.parse(fs.readFileSync(setupFilePath, 'utf-8'));
|
||||
|
||||
passport.use(new DiscordStrategy({
|
||||
clientID: setupData.discord.clientID,
|
||||
clientSecret: setupData.discord.clientSecret,
|
||||
callbackURL: `http://${setupData.domain}/auth/discord/callback`
|
||||
clientID: setupData[0].discord.clientID,
|
||||
clientSecret: setupData[0].discord.clientSecret,
|
||||
callbackURL: `http://${setupData[0].domain}/auth/discord/callback`
|
||||
}, (accessToken, refreshToken, profile, done) => {
|
||||
fs.readFile('user.json', 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
@@ -19,7 +19,7 @@ passport.use(new DiscordStrategy({
|
||||
const users = JSON.parse(data);
|
||||
const user = users.find(user => user.id === profile.id);
|
||||
|
||||
if (setupData.discord.authorizedIDs.length > 0 && !setupData.discord.authorizedIDs.includes(profile.id)) {
|
||||
if (setupData[0].discord.authorizedIDs.length > 0 && !setupData[0].discord.authorizedIDs.includes(profile.id)) {
|
||||
return done(null, false, { message: 'L\'utilisateur n\'est pas autorisé.' });
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ passport.serializeUser((user, done) => {
|
||||
});
|
||||
|
||||
passport.deserializeUser((id, done) => {
|
||||
fs.readFile('user.json', 'utf8', (err, data) => {
|
||||
fs.readFile('/data', 'user.json', 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
@@ -43,4 +43,4 @@ passport.deserializeUser((id, done) => {
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = passport;
|
||||
module.exports = passport;
|
||||
Reference in New Issue
Block a user