diff --git a/src/config/passport.js b/src/config/passport.js deleted file mode 100644 index a40f7a1..0000000 --- a/src/config/passport.js +++ /dev/null @@ -1,42 +0,0 @@ -var secret = require('.').secret, -bcrypt = require('bcrypt'); -const passport = require('passport'); -var LocalStrategy = require('passport-local').Strategy; -var HeaderAPIKeyStrategy = require('passport-headerapikey').HeaderAPIKeyStrategy; -var mongoose = require('mongoose'); -var Application = mongoose.model('Application'); -//var User = mongoose.model('User'); -const { UserService } = require('../services'); - - -passport.use('headerapikey', new HeaderAPIKeyStrategy( - { header: 'Authorization', prefix: `${process.env.AUTHORIZATION_PREFIX} ` }, - false, - function (apikey, done) { - const salt = secret; - Promise.resolve(bcrypt.hash(apikey, salt)).then(function (encryptedKey) { - Application.findOne({ encryptedKey: encryptedKey }) - .populate('author') - .then(function (application) { - if (!application) { - return done({message: "Application can't be found.", status: 404}, false, false); - } - return done(null, application); - }); - }).catch(done); - } -)); - -passport.use('local', new LocalStrategy({ - usernameField: 'user[email]', - passwordField: 'user[password]' -}, function (email, password, done) { - UserService.getUserByEmail({ email }).then(function (user) { - //User.findOne({ email: email }).then(function (user) { - //console.log(user); - if (!user || !user.validPassword(password)) { - return done(null, false, { errors: { 'email ou mot de passe': 'invalide' } }); - } - return done(null, user); - }).catch(done); -})); diff --git a/src/controllers/user.controller.js b/src/controllers/user.controller.js index 0f9feba..2b12657 100644 --- a/src/controllers/user.controller.js +++ b/src/controllers/user.controller.js @@ -39,7 +39,6 @@ const getUser = async (req, res) => { try { const user = await UserService.getUserById(req.payload.id); - console.log(req.payload); res.status(200).json({ user: user.toAuthJSON(), }); diff --git a/src/database/connectDb.js b/src/database/connectDb.js index 4e24655..97ad25e 100644 --- a/src/database/connectDb.js +++ b/src/database/connectDb.js @@ -34,7 +34,6 @@ const connectMongoDb = async () => { const connectMysqlDb = async () => { try { await sequelize.authenticate(); - console.log('Connection has been established successfully 🔹'); console.log(`${utils.getDateTimeISOString()}`, chalk.green('MySQL connection has been established successfully 🟢')); // Synchronize the database with the models without need of dropping the tables diff --git a/src/routes/api/users.js b/src/routes/api/users.js index 9921fb1..1ba7768 100644 --- a/src/routes/api/users.js +++ b/src/routes/api/users.js @@ -97,7 +97,6 @@ router.get('/authenticate', function (req, res, next) { })(req, res, next); }); router.post('/users', function (req, res, next) { - console.log('ici post users'); let user = new User(); if (typeof req.body.user.username !== 'undefined') { user.username = req.body.user.username; diff --git a/src/routes/utils.js b/src/routes/utils.js index caa5f0c..c4145a7 100644 --- a/src/routes/utils.js +++ b/src/routes/utils.js @@ -63,7 +63,6 @@ const utils = { if (response.status >= 200 && response.status < 400) { console.log(`${utils.getDateTimeISOString()}`, chalk.green(`Réception des sauts via SkydiverId API`), `${response.status} ${response.statusText}`); const data = response.json(); - console.log(data); return data; } else { console.log(`${utils.getDateTimeISOString()}`, chalk.red(`Erreur ${response.status} ${response.statusText}`)); diff --git a/src/utils/index.js b/src/utils/index.js index caa5f0c..c4145a7 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -63,7 +63,6 @@ const utils = { if (response.status >= 200 && response.status < 400) { console.log(`${utils.getDateTimeISOString()}`, chalk.green(`Réception des sauts via SkydiverId API`), `${response.status} ${response.statusText}`); const data = response.json(); - console.log(data); return data; } else { console.log(`${utils.getDateTimeISOString()}`, chalk.red(`Erreur ${response.status} ${response.statusText}`));