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:
@@ -4,16 +4,17 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { getUserData } = require('../Middlewares/watcherMiddleware');
|
||||
|
||||
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('ActiveDirectory', new ActiveDirectoryStrategy({
|
||||
integrated: false,
|
||||
ldap: {
|
||||
url: setupData.ldap.url,
|
||||
baseDN: setupData.ldap.baseDN,
|
||||
username: setupData.ldap.username,
|
||||
password: setupData.ldap.password
|
||||
url: setupData[0].ldap.url,
|
||||
baseDN: setupData[0].ldap.baseDN,
|
||||
username: setupData[0].ldap.username,
|
||||
password: setupData[0].ldap.password
|
||||
}
|
||||
}, function (profile, ad, done) {
|
||||
ad.isUserMemberOf(profile._json.dn, 'CDN-Access', function (err, isMember) {
|
||||
@@ -44,3 +45,4 @@ passport.deserializeUser(async (id, done) => {
|
||||
});
|
||||
|
||||
module.exports = passport;
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -1,11 +1,14 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { logger, ErrorLogger, logRequestInfo } = require('../config/logs');
|
||||
|
||||
const dataFolderPath = path.join(__dirname, '../data');
|
||||
const filesToCreate = ['setup.json', 'user.json', 'file_info.json'];
|
||||
|
||||
filesToCreate.forEach((fileName) => {
|
||||
if (!fs.existsSync(fileName)) {
|
||||
fs.writeFileSync(fileName, '{}');
|
||||
const filePath = path.join(dataFolderPath, fileName);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
fs.writeFileSync(filePath, '[]');
|
||||
logger.info(`${fileName} created successfully.`);
|
||||
} else {
|
||||
logger.info(`${fileName} already exists.`);
|
||||
|
||||
Reference in New Issue
Block a user