diff --git a/index.js b/index.js index 56e8f96..9a85c06 100644 --- a/index.js +++ b/index.js @@ -24,20 +24,6 @@ let TokenDurationSecond = 3600; let MaxAmountCrepe = 10; let Supplements = ["nature", "sucre", "nutella", "confiture"]; -// var ldapConf = JSON.parse(fs.readFileSync("ldap-conf.json")); -// var LDAP = new LdapAuth({ -// url: 'ldap://10.5.0.44', -// bindDN: 'cn='+ ldapConf.bindUser +',ou=service-users,dc=ldap,dc=rezo-rm,dc=fr', -// bindCredentials: ldapConf.bindPassword, -// searchBase: 'dc=ldap,dc=rezo-rm,dc=fr', -// searchFilter: '(uid={{username}})', -// reconnect: true, -// }); -// LDAP.on('error', function (err) { -// console.error('LdapAuth: ', err); -// }); -// ldapConf = null; - fastify.addContentTypeParser('application/json', { parseAs: 'string' }, function(req, body, done) { @@ -59,40 +45,6 @@ fastify.get('/', async (request, reply) => { reply.redirect('/index.html') }) -// fastify.post('/login', async (request, reply) => { -// let content = request.body; -// if (content.hasOwnProperty("user") -// && content.hasOwnProperty("password")) { -// let res = await authenticate(content.user, content.password); -// if (res.authState) { -// let now = new Date(); -// UsersToken[res.authUser.uid] = { -// token: makeid(64), -// expire: now.setSeconds(now.getSeconds() + TokenDurationSecond) -// } -// return { -// success: true, -// user: { -// uid: res.authUser.uid, -// givenName: res.authUser.givenName, -// isAdmin: AdminUsersUid.includes(res.authUser.uid) -// }, -// token: UsersToken[res.authUser.uid].token -// } -// } else { -// return { -// success: false, -// why: "Wrong username or password" -// } -// } -// } else { -// return { -// success: false, -// why: "The username or password is missing" -// } -// } -// }) - fastify.post('/login', async (request, reply) => { let content = request.body; if (content.hasOwnProperty("user") @@ -721,24 +673,6 @@ function saveData(path, data) { fs.writeFileSync(path, JSON.stringify(data)); } -// function authenticate(user, pwd) { -// return new Promise((resolve, reject) => { -// LDAP.authenticate(user, pwd, function(err, user) { -// if (user && err == null) { -// resolve({ -// authState: true, -// authUser: user -// }); -// } else { -// resolve({ -// authState: false, -// authUser: null -// }); -// } -// }); -// }) -// } - function checkAuthetification(content) { if (content.hasOwnProperty("uid") && content.hasOwnProperty("token")) {