commit 30 05 2018 v4

anis
Tmadkaud 6 years ago
parent f7d864bf98
commit c1091339b9

@ -8,11 +8,7 @@ var User = require('../models/user');
passport.use(new FacebookStrategy({
clientID: "191092458179642",
clientSecret: "964e490d7e49a13ee7a77c9b65419fb3",
<<<<<<< HEAD
callbackURL: "http://127.0.0.1:3000/api/facebook/callback"
=======
callbackURL: "https://localhost:3000/api/facebook/callback"
>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc
},
function(accessToken, refreshToken, profile, done) {
console.log('yaaauuu : ' + accessToken + ' ----- ' + profile.displayName + ' ----- ' + profile.id);
@ -38,9 +34,4 @@ passport.use(new FacebookStrategy({
});*/
}
));
<<<<<<< HEAD
module.exports = passport;
=======
module.exports = passport;
>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc
module.exports = passport;

@ -591,7 +591,7 @@ module.exports = "body {\r\n padding-top: 40px;\r\n padding-bottom: 40px;\r\n
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = "<div class=\"container\">\r\n <form class=\"form-signin\" (ngSubmit)=\"login()\" #loginForm=\"ngForm\">\r\n <div class=\"alert alert-warning alert-dismissible\" role=\"alert\" *ngIf=\"message !== ''\">\r\n <button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>\r\n {{message}}\r\n </div>\r\n <h2 class=\"form-signin-heading\">Please sign in</h2>\r\n <label for=\"inputEmail\" class=\"sr-only\">Email address</label>\r\n <input type=\"email\" class=\"form-control\" placeholder=\"Email address\" [(ngModel)]=\"loginData.username\" name=\"username\" required/>\r\n <label for=\"inputPassword\" class=\"sr-only\">Password</label>\r\n <input type=\"password\" class=\"form-control\" placeholder=\"Password\" [(ngModel)]=\"loginData.password\" name=\"password\" required/>\r\n <button class=\"btn btn-lg btn-primary btn-block\" type=\"submit\" [disabled]=\"!loginForm.form.valid\">Sign in</button>\r\n <p>\r\n Not a member? <a [routerLink]=\"['/signup']\">Signup here</a>\r\n </p>\r\n </form>\r\n</div>\r\n\r\n\r\n\r\n<button onclick=\"location.href='/api/facebook'\" type=\"button\" class=\"btn-floating btn-fb\"><i class=\"fa fa-facebook\"></i></button>\r\n<button onclick=\"location.href='/api/github'\" type=\"button\" class=\"btn-floating btn-git\"><i class=\"fa fa-github\"></i></button>\r\n<button onclick=\"location.href='/api/google'\" type=\"button\" class=\"btn-floating btn-gplus\"><i class=\"fa fa-google\"></i></button>\r\n<button type=\"button\" class=\"btn-floating btn-fb\" (click)=\"facebook()\"><i class=\"fa fa-facebook\"></i></button>\r\n"
module.exports = "<div class=\"container\">\r\n <form class=\"form-signin\" (ngSubmit)=\"login()\" #loginForm=\"ngForm\">\r\n <div class=\"alert alert-warning alert-dismissible\" role=\"alert\" *ngIf=\"message !== ''\">\r\n <button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>\r\n {{message}}\r\n </div>\r\n <h2 class=\"form-signin-heading\">Please sign in</h2>\r\n <label for=\"inputEmail\" class=\"sr-only\">Email address</label>\r\n <input type=\"email\" class=\"form-control\" placeholder=\"Email address\" [(ngModel)]=\"loginData.username\" name=\"username\" required/>\r\n <label for=\"inputPassword\" class=\"sr-only\">Password</label>\r\n <input type=\"password\" class=\"form-control\" placeholder=\"Password\" [(ngModel)]=\"loginData.password\" name=\"password\" required/>\r\n <button class=\"btn btn-lg btn-primary btn-block\" type=\"submit\" [disabled]=\"!loginForm.form.valid\">Sign in</button>\r\n <p>\r\n Not a member? <a [routerLink]=\"['/signup']\">Signup here</a>\r\n </p>\r\n\r\n <button onclick=\"location.href='/api/facebook'\" type=\"button\" class=\"btn-floating btn-fb\"><i class=\"fa fa-facebook\"></i></button>\r\n <button onclick=\"location.href='/api/github'\" type=\"button\" class=\"btn-floating btn-git\"><i class=\"fa fa-github\"></i></button>\r\n <button onclick=\"location.href='/api/google'\" type=\"button\" class=\"btn-floating btn-gplus\"><i class=\"fa fa-google\"></i></button>\r\n </form>\r\n</div>\r\n<<<<<<< HEAD\r\n\r\n\r\n\r\n<button onclick=\"location.href='/api/facebook'\" type=\"button\" class=\"btn-floating btn-fb\"><i class=\"fa fa-facebook\"></i></button>\r\n<button onclick=\"location.href='/api/github'\" type=\"button\" class=\"btn-floating btn-git\"><i class=\"fa fa-github\"></i></button>\r\n<button onclick=\"location.href='/api/google'\" type=\"button\" class=\"btn-floating btn-gplus\"><i class=\"fa fa-google\"></i></button>\r\n<button type=\"button\" class=\"btn-floating btn-fb\" (click)=\"facebook()\"><i class=\"fa fa-facebook\"></i></button>\r\n=======\r\n>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc\r\n"
/***/ }),

File diff suppressed because one or more lines are too long

@ -39,10 +39,7 @@
"express": "^4.16.2",
"express-fileupload": "^0.4.0",
"express-session": "^1.15.6",
<<<<<<< HEAD
"find-or-create": "^1.1.0",
=======
>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc
"font-awesome": "4.7.x",
"form-data": "^2.3.2",
"gulp": "^3.9.1",

@ -18,13 +18,10 @@ var passportFacebook = require('../auth/facebook');
var passportGoogle = require('../auth/google');
var passportGitHub = require('../auth/github');
<<<<<<< HEAD
//var router = express.Router([options]);
=======
>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc
/* creation Token */
getToken = function (headers) {
if (headers && headers.authorization) {
@ -52,36 +49,36 @@ const storage = multer.diskStorage({
/* GET home page. */
router.get('/', function(req, res, next) {
res.send('Express RESTful API');
res.send('Express RESTful API');
});
router.post('/signup', function(req, res) {
if (!req.body.username || !req.body.password) {
res.json({success: false, msg: 'Please pass username and password.'});
} else {
var newUser = new User({
username: req.body.username,
password: req.body.password
});
// save the user
newUser.save(function(err) {
if (err) {
return res.json({success: false, msg: 'Username already exists.'});
}
res.json({success: true, msg: 'Successful created new user.'});
});
}
if (!req.body.username || !req.body.password) {
res.json({success: false, msg: 'Please pass username and password.'});
} else {
var newUser = new User({
username: req.body.username,
password: req.body.password
});
// save the user
newUser.save(function(err) {
if (err) {
return res.json({success: false, msg: 'Username already exists.'});
}
res.json({success: true, msg: 'Successful created new user.'});
});
}
});
/* SAVE FILE */
router.post('/uploadFileMongo', function(req, res, next) {
FileMongo.create(req.body, function (err, post) {
if (err){
return next(err);
}
res.json(post);
});
FileMongo.create(req.body, function (err, post) {
if (err){
return next(err);
}
res.json(post);
});
});
/* SAVE URL FILE */
@ -110,15 +107,15 @@ router.post('/createFolder', function(req, res, next) {
/* DELETE FILE */
router.post('/deleteFileMongo', function(req, res, next) {
FileMongo.remove(req.body, function (err, post) {
if (err){
return next(err);
}
//Delete file multer dans Public
fs.unlink('./public/' + req.body._id);
res.json(post);
FileMongo.remove(req.body, function (err, post) {
if (err){
return next(err);
}
//Delete file multer dans Public
fs.unlink('./public/' + req.body._id);
res.json(post);
});
});
});
/* DELETE FOLDER */
@ -233,28 +230,28 @@ router.post('/getFileList', function(req, res) {
/* Login */
router.post('/signin', function(req, res) {
User.findOne({
username: req.body.username
}, function(err, user) {
if (err) throw err;
User.findOne({
username: req.body.username
}, function(err, user) {
if (err) throw err;
if (!user) {
res.status(401).send({success: false, msg: 'Authentication failed. User not found.'});
} else {
// check if password matches
user.comparePassword(req.body.password, function (err, isMatch) {
if (isMatch && !err) {
console.log('req.user.username log : ' + JSON.stringify(user));
// if user is found and password is right create a token
var token = jwt.sign(user.toJSON(), config.secret);
// return the information including token as JSON
res.json({success: true, token: 'JWT ' + token});
if (!user) {
res.status(401).send({success: false, msg: 'Authentication failed. User not found.'});
} else {
res.status(401).send({success: false, msg: 'Authentication failed. Wrong password.'});
// check if password matches
user.comparePassword(req.body.password, function (err, isMatch) {
if (isMatch && !err) {
console.log('req.user.username log : ' + JSON.stringify(user));
// if user is found and password is right create a token
var token = jwt.sign(user.toJSON(), config.secret);
// return the information including token as JSON
res.json({success: true, token: 'JWT ' + token});
} else {
res.status(401).send({success: false, msg: 'Authentication failed. Wrong password.'});
}
});
}
});
}
});
});
});
@ -265,13 +262,13 @@ router.post('/upload' , multer({storage: storage, limits: {fileSize: 30000000000
/* Get utilisateur courant */
router.get('/getCurrentUser', passport.authenticate('jwt', { session: false}), function(req, res) {
var token = getToken(req.headers);
var token = getToken(req.headers);
if (token) {
res.json(req.user);
} else {
return res.status(403).send({success: false, msg: 'Unauthorized.'});
}
if (token) {
res.json(req.user);
} else {
return res.status(403).send({success: false, msg: 'Unauthorized.'});
}
});
@ -293,20 +290,15 @@ function ensureAuthenticated(req, res, next) {
/* FACEBOOK ROUTER */
router.get('/facebook', passportFacebook.authenticate('facebook'));
<<<<<<< HEAD
///////////////////
router.get('/facebook/callback',
passportFacebook.authenticate('facebook', { failureRedirect: 'api/' }),
function(req, res) {
console.log('faceeeeboookk !!');
=======
router.get('/facebook/callback', passportFacebook.authenticate('facebook', { successRedirect : '/', failureRedirect: '/login' }), function(req, res) {
>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc
// Successful authentication, redirect home.
res.redirect('/api/main');
});
<<<<<<< HEAD
// router.get('/facebook/callback/:id', passport.authenticate('facebook'), function(req, res, err, user, info){
// console.log('faceeeeboookk !!');
//
@ -356,49 +348,27 @@ router.get('/facebook/callback', passportFacebook.authenticate('facebook', { suc
// router.get('/facebook',
// passportFacebook.authenticate('facebook', { scope: ['read_stream', 'publish_actions'] })
// );
=======
router.get('/facebook',
passport.authenticate('facebook', { scope: ['read_stream', 'publish_actions'] })
);
>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc
/* GOOGLE ROUTER */
router.get('/google', passportGoogle.authenticate('google', { scope: 'https://www.google.com/m8/feeds' }));
router.get('/google/callback', passportGoogle.authenticate('google', { successRedirect : '/', failureRedirect: '/login' }), function(req, res) {
<<<<<<< HEAD
res.redirect('/');
});
router.get('/google',
passport.authenticate('google', { scope: ['read_stream', 'publish_actions'] })
);
=======
res.redirect('/');
});
router.get('/google',
passport.authenticate('google', { scope: ['read_stream', 'publish_actions'] })
);
>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc
/* GITHUB ROUTER */
router.get('/github', passportGitHub.authenticate('github', { scope: [ 'user:email' ] }));
router.get('/auth/github/callback', passportGitHub.authenticate('github', { successRedirect : '/', failureRedirect: '/login' }), function(req, res) {
<<<<<<< HEAD
// Successful authentication, redirect home.
res.redirect('/');
});
router.get('/github',
passport.authenticate('github', { scope: ['read_stream', 'publish_actions'] })
);
=======
// Successful authentication, redirect home.
res.redirect('/');
});
router.get('/github',
passport.authenticate('github', { scope: ['read_stream', 'publish_actions'] })
);
>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc
module.exports = router;

@ -13,13 +13,8 @@
<p>
Not a member? <a [routerLink]="['/signup']">Signup here</a>
</p>
<button onclick="location.href='/api/facebook'" type="button" class="btn-floating btn-fb"><i class="fa fa-facebook"></i></button>
<button onclick="location.href='/api/github'" type="button" class="btn-floating btn-git"><i class="fa fa-github"></i></button>
<button onclick="location.href='/api/google'" type="button" class="btn-floating btn-gplus"><i class="fa fa-google"></i></button>
</form>
</div>
<<<<<<< HEAD
@ -27,5 +22,3 @@
<button onclick="location.href='/api/github'" type="button" class="btn-floating btn-git"><i class="fa fa-github"></i></button>
<button onclick="location.href='/api/google'" type="button" class="btn-floating btn-gplus"><i class="fa fa-google"></i></button>
<button type="button" class="btn-floating btn-fb" (click)="facebook()"><i class="fa fa-facebook"></i></button>
=======
>>>>>>> 98b837065bd51764d8da85c7972979c9fcf214dc

Loading…
Cancel
Save