From c2bdbd20f809829bdff3e87b15c758567fbd68c0 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 11 Jul 2019 18:50:30 +0200 Subject: [PATCH 01/40] github patch --- app.js | 4 ++-- bin/seeds.js | 12 ++++++------ bin/www | 4 +++- passport/facebookStrategy.js | 3 +-- passport/githubStrategy.js | 3 +-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app.js b/app.js index 9dcd84b..6c61b76 100644 --- a/app.js +++ b/app.js @@ -15,7 +15,7 @@ const flash = require("connect-flash"); const axios = require('axios'); mongoose - .connect(process.env.MONGODB_URI || 'mongodb://localhost/project2', {useNewUrlParser: true}) + .connect(process.env.MONGO_URI || 'mongodb://localhost/project2', {useNewUrlParser: true}) .then(x => { console.log(`Connected to Mongo! Database name: "${x.connections[0].name}"`) }) @@ -77,7 +77,7 @@ app.locals.title = 'Express - Generated with IronGenerator'; // Enable authentication using session + passport app.use(session({ - secret: 'irongenerator', + secret: process.env.SESSION_SECRET, resave: true, saveUninitialized: true, store: new MongoStore( { mongooseConnection: mongoose.connection }) diff --git a/bin/seeds.js b/bin/seeds.js index 931fc71..0456a18 100644 --- a/bin/seeds.js +++ b/bin/seeds.js @@ -58,7 +58,7 @@ let sources = [ category: "general", language: "en", country: "gb", - reputation: 4.3, + reputation: 231, comments: [], profileImg: `https://liquidcinemavr.com/wp-content/uploads/2019/03/bbc-logo.jpg`, politicalBias: "The BBC has historically been a centre-right organisation. It's a publically funded, urban organisation with a higher proportion of young people and ethnic minorities. Therefore it tends to hold a liberal bias and, whilst it aligns with the Liberal Party ideals, it also closely allies with the Tories. Writers can often flex their own political opinions and agendas so it's best to be aware.", @@ -77,7 +77,7 @@ let sources = [ category: "general", language: "en", country: "us", - reputation: 4.2, + reputation: 97, comments: [], profileImg: `https://s.abcnews.com/assets/beta/assets/abcn_images/abcnews_pearl_stacked.png`, politicalBias: "ABC is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, ABC holds a centre left swing with a left leaning and liberal view on many convtroversial topics. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", @@ -94,7 +94,7 @@ let sources = [ category: "business", language: "en", country: "us", - reputation: 4.1, + reputation: 211, comments: [], profileImg: `https://amp.businessinsider.com/images/597a0306b50ab126008b4b46-750-342.png`, politicalBias: 'Business Insider is a privately held corporation and, as such, is more susceptible to the political leanings of it\'s leaders. Therefore readers should be aware that the company owners, Brian Anthony and Chris Gunning, are staunchly left-wing and liberal thinkers. This can be conveyed through the leanings of the content that is present in both the print and online editions of Business Insider.', @@ -111,7 +111,7 @@ let sources = [ category: "general", language: "en", country: "us", - reputation: 4.2, + reputation: 56, comments: [], profileImg: `https://www.nlgja.org/wp-content/uploads/2018/01/Reuters-logo-square-2017.png`, politicalBias: "Reuters is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, Reuters holds a centre political stance with a left leaning and liberal view on many convtroversial topics. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", @@ -128,7 +128,7 @@ let sources = [ category: "general", language: "en", country: "us", - reputation: 4.2, + reputation: 52, comments: [], profileImg: `https://upload.wikimedia.org/wikipedia/commons/b/b1/CNN.svg`, politicalBias: "CNN is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", @@ -144,7 +144,7 @@ let sources = [ category: "general", language: "en", country: "us", - reputation: 4.2, + reputation: 112, comments: [], profileImg: `https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/CNBC_logo.svg/701px-CNBC_logo.svg.png`, politicalBias: "CNN is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", diff --git a/bin/www b/bin/www index 127267d..161a0cb 100644 --- a/bin/www +++ b/bin/www @@ -41,6 +41,8 @@ server.on('error', error => { } }); -server.listen(process.env.PORT || 'https://opinion-news.herokuapp.com/', () => { +server.listen(process.env.PORT + // || 'https://opinion-news.herokuapp.com/' + , () => { console.log(`Listening on http://localhost:${process.env.PORT}`); }); diff --git a/passport/facebookStrategy.js b/passport/facebookStrategy.js index 8b1ad0f..49f1750 100644 --- a/passport/facebookStrategy.js +++ b/passport/facebookStrategy.js @@ -5,8 +5,7 @@ const User = require('../models/User'); passport.use(new FacebookStrategy({ clientID: process.env.FACEBOOK_USER_ID, clientSecret: process.env.FACEBOOK_KEY, - callbackURL: 'https://opinion-news.herokuapp.com/auth/facebook/callback' - // "http://localhost:3000/auth/facebook/callback" + callbackURL: "http://localhost:3000/auth/facebook/callback" }, function(accessToken, refreshToken, profile, cb) { User.findOne({ facebookId: profile.id }).then(user => { diff --git a/passport/githubStrategy.js b/passport/githubStrategy.js index 103082e..3dc1fb7 100644 --- a/passport/githubStrategy.js +++ b/passport/githubStrategy.js @@ -5,8 +5,7 @@ const User = require('../models/User'); passport.use(new GitHubStrategy({ clientID: process.env.GITHUB_CLIENT_ID, clientSecret: process.env.GITHUB_CLIENT_SECRET, - callbackURL: 'https://opinion-news.herokuapp.com/auth/github/callback' - // "http://localhost:3000/auth/github/callback" + callbackURL: "http://localhost:3000/auth/github/callback" }, function(accessToken, refreshToken, profile, cb) { User.findOne({ githubId: profile.id }) From 41da8c5e1363580143fd3523e15fb0566f95547b Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 11 Jul 2019 19:50:35 +0200 Subject: [PATCH 02/40] added favicon --- app.js | 1 - public/images/favicon.ico | Bin 36263 -> 405 bytes 2 files changed, 1 deletion(-) diff --git a/app.js b/app.js index 6c61b76..8be7e31 100644 --- a/app.js +++ b/app.js @@ -56,7 +56,6 @@ app.use(express.static(path.join(__dirname, 'public'))); app.use(favicon(path.join(__dirname, 'public', 'images', 'favicon.ico'))); hbs.registerHelper('title', data => { - console.log(data[0]); return data // return title.replace(/ \- [\w\s]*/, ''); }) diff --git a/public/images/favicon.ico b/public/images/favicon.ico index 99e29b974238f09ba1921daf725564b8868a3c61..9e72ccee0795a15a55696104f867b100741f7e6c 100644 GIT binary patch literal 405 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbMfq5z)|SN8%RAagK-nJoJ!1Knp@ z666=m@bY7)+#Ol5CW&izFLyalcVhV#aZZ_ehQecw68SItuitMdc<@j9^Y;%j?G=q> zmrAQ{S6X_9$D!u7|lCpJqNZuqS5ap%^?nly`eH^1P1sM@-L*YZhb#>x^BODJ=4q#!*GUq-*@k=Tlao%RlRzz zUr(bkqj6N@#1k9g-@L{HpKUaj97OZt`Tzd&@1P04gM9H~$>uj2SI=%V&JBWt4d;db zGd}&@Xbc9+&VQkO{FyOY)Ve&jY{@}esI^jX)c%8qT5X#PV_#YC>YUg-M2n`uMMtS= zt-gt|HMe^dO*!?Vs4FAd))(Zkh;rbVsPnw`Cyw4dw~sY$Hg=DV>_8VOP0)a3WMcy{ zXs|=;#fz-{NOaiV9FMdEtx}&1>kX1U8`029c6?cyYJ$ zkgw+>+WDp=YlR*a`nJ#+5$$;4ZeGLTrSlGv4SEEhB@rULVNXo1*L1aq&p+ z*x(gee~{;y2%0A-?c&PNvdM#We(qEmZNpjNcdE#)D8^p9m|-x)3`6Fj=BmgbEX^+ZK{wga z9E-i3cF`+hcCgVO1e2LRW3oLn_Bk)bGHLj17m+m2>g1>HRW!>xx(L6kWz|c1TO@I zYhKSGW7wwcr3nD*Prg>-gFXRmC$UFpxi=)f%8-x~wmitk(9^zh&ww6HX zje9z@AY%Tq;zKqTG;nfs*qj@Wbs3{iqU0$F2<;L@Zkx1l&QlVuvOMv+SS^sj_TAFn zEJVLNr?Jabu;B><(Nig8)d+@~_S7;RGmRqhe8CCTd`vAK5;{-Fo(FETCvl(rQW~Ce z8G}PFM&0&T<8l8-vVB5mo!Pu1$t^;*Jned25*r%foD99ZJQ*#-lChR))RX7IV{4OI zJRoFl!@04w;|J2M6^dZ@yB&gXYByKgdD=NoM#o3A{k3@9`9?hM{;@2mWZk^HT(h>e z4{i5>tw$B5g>A#>9F@hNv@A*=UbB8E3{dNY5Bz{8?xaiiwK~J^n0Iz zv@HosA0=cO#XvidH@ujP_IxvVAVYidF+}lCi9PK4VLWCJp^d#DUmtbbnQ|vZN%;La z)7g~UX#;on+p=IOU@7dKw~P}TUj1NeqoQPFER^h~h_<~XiA|<(ezRl(&}``qe-L$_ z{3;%|;^=9$S}A0+I4jO+(vd#puST@cePNIDks>kB7AT@~gxDQ;t1acXEn#R!V}A3a~XV#+HO^t=)oh}J;)CCC?K3nQ{ut1c`AQ}G96*C0t z5{KQ`DIDuiT&tX%K^1flN}mHR8M!p#=SoqBd||TwRB7_d60$ zX^AQTJ0{x|cGzyv`4vJr;3CFYtBZ&=5Uv zEn{SsWS0ur&MTasDH&ea7jy9-Dk7-Ps9KvbWc%ml>=;UQJ5LLDAQ(f&67D@BA|m=A zYnZ^F*MffWLJLoeU0sy*d#cJe!`QRVumRzph>#uL$jgY#sbh;BsWBFKD^P2GWV8Le z9pfSV#^>S97txbZhAi(EcQOS>fs8^{epH@T#_ImiPId%GM4BEf!AQviy1FQR#Jl*I z&?5Y_?4}_b%TaMqH_1`+sug@zT%U28%i1Wzk#{`(zGf=uy)h+dZy&y?8xO%Raq)R9ySh ziyP_aF_v}}Twho}xrg;owl3Jp>-k4EU1_+ei&EvPxErw2W%Dk$k3ZCn`et>L9Wt-_ zS=(#Xq!@P%yAG$AgJofJq{$K|?TWQD-6v-(i)89Yh5Cc2Gbr=SW3!@$X)LDPj*Ob7 zti5d8vtz+B{>Gt#UT>bv8$+xWY4mw{rJScmrK{%PBHN*~irp`-iDjIrx*p#XCG+Y` zEEg0{IjMLRGgwVLO5?FQlJ#JVr>&)D498 z$VIT>&FJ>^kw>p`iT`x;Y^r5dBcyFZkji*t(%Z4pVjATu5|swQ(BezFSGuZBRJa@m zi|mR|<>=2FZD^-aUb)`c@YrRpTx8Eqsa;xAk(AYJnp2`-XNqhZjjeLM^XJvNy{2tW*wL1EHt2&T4}_NZJek+qQsqnA z{va~K-;%S`U9k&mt&Tdc9Ukf;FV`=r^K*pgjTY3Aca(T}d9KRHsC{_cqRg5j2dKkA-=l&)wLtb^oeW;wXE%3kuZBj z)=m5LJ9JvqwRuMjC9`&7tB!+J?lQGC28aI`CA&Z9)P!@Y2H!HXyS?E*Maj@R(qK%- zsXMdY{l2W77fBENBWm~mH6FLVEbH|`IpCE)`i}a&e~=xjey_+`ZPu#0qLOL$X4W#U zt{++mEh@S1FVWkc-^wc)FLz`T1+Y;kPYUIL8$JqfTW%oCoR`QQ8pHs{fD+!u%#WD-3ip-*FyK zS4zrK%A!rLo#oBuraWMMp=2!86SD-DrR_bAs?s{V@BdiYSA)l;Hs;cT?k)q-c<3i; z#J)+Q0It;uw}f1oPm%T(p>BY3^1&TfMrSjUlha%cT~Mo zSzX+E^YsvyG;KHc{@%&`D#=b0%E1<$z?Y$|uS%DLO*%PN$Xe`tR}z7=Y7hNXB1+D^ zj+6lq$?9Aju{(Va;m){X@6?aFG9q~{bF#92Oo%0vI?@6!&#ML8Es%`yYS+pgKa!5^ z3Rdja=R~`0-;2jI;}87P$4Q(If3x4o_i&JZGk>iJh!i@&OS)_&BJh**Rf zon#N91zX2rW(8*0^RN?{CC2avV(-ER7j1tKBacg{=b2b&LFQvY6H#0G*KP4X#n5TXIjrT*c9-&9sMZk`k^{qd1d;ChxjAlhM7P8xuJaO)D z>>eyv3h(-bpn$veepu>mfTDo9*;*2NK6DN2;rTtmCGX3xTMvzzmio-kX;g=%*s)tfDq($B%xSMswG zXAgesUGjsA5h{IK>?K=2)a|~H1arXFE|=z*E#$;hx!H&7^jH?}J99E3&aUkg1XMPN z66QuX3w(gO+1gF;-rsdIaOETW<>v12tv9RqpjfcX5By7#9I!8A%b4qhx4kClg7hdO zC`aHrjiRiD>k&`sQ|4}F*@`nl-@(IFs5A4rxXtp`z>xK3ac66#&PNAsP%{{RO0r%7 zTSoJi-GjNl=oI7{1|fUzMKWPyRd*}q+2JKE)}ezL>cmjeW!5tByw;WRwBu6wqby4$ zV>ug?j0^8N$*vQEQ=Un9&mOV6Rc*f}gcd|p^JTY6=u9Ch#Zc!%w`}yume$1+R_K{A@lmh zA6i=Ag+AyPKD`!VS3{jZ|$|gUO7w z`?^=LTyd#WHLCi4*|M3j$EMvk5FeuqSr(}RJb0Yh-m-V%vPyn2lPtxaj$Uk&`)@5! zH7d!<)4Voh6n~2Pr7>QWyT`}jD65*s Date: Fri, 12 Jul 2019 08:47:28 +0200 Subject: [PATCH 03/40] checking master --- passport/facebookStrategy.js | 40 ++++++++--------- passport/githubStrategy.js | 84 ++++++++++-------------------------- routes/homepages.js | 8 ++-- routes/profiles.js | 5 +-- 4 files changed, 47 insertions(+), 90 deletions(-) diff --git a/passport/facebookStrategy.js b/passport/facebookStrategy.js index 733c105..4c259b7 100644 --- a/passport/facebookStrategy.js +++ b/passport/facebookStrategy.js @@ -2,23 +2,23 @@ const FacebookStrategy = require("passport-facebook").Strategy; const passport = require('passport'); const User = require('../models/User'); -passport.use(new FacebookStrategy({ - clientID: process.env.FACEBOOK_USER_ID, - clientSecret: process.env.FACEBOOK_KEY, - callbackURL: "http://localhost:3000/auth/facebook/callback" - }, - function(accessToken, refreshToken, profile, cb) { - User.findOne({ facebookId: profile.id }).then(user => { - if (user) return cb(null, user); - console.log('FB user: ' + user) - return User.create({ - facebookId: profile.id, - fullName: profile.displayName - }).then(newUser => { - return cb(null, newUser); - }); - }).catch(err => { - cb(err); - }); - } -)); +// passport.use(new FacebookStrategy({ +// clientID: process.env.FACEBOOK_USER_ID, +// clientSecret: process.env.FACEBOOK_KEY, +// callbackURL: "http://localhost:3000/auth/facebook/callback" +// }, +// function(accessToken, refreshToken, profile, cb) { +// User.findOne({ facebookId: profile.id }).then(user => { +// if (user) return cb(null, user); +// console.log('FB user: ' + user) +// return User.create({ +// facebookId: profile.id, +// fullName: profile.displayName +// }).then(newUser => { +// return cb(null, newUser); +// }); +// }).catch(err => { +// cb(err); +// }); +// } +// )); diff --git a/passport/githubStrategy.js b/passport/githubStrategy.js index 3dc1fb7..d1ac9c3 100644 --- a/passport/githubStrategy.js +++ b/passport/githubStrategy.js @@ -2,65 +2,27 @@ const GitHubStrategy = require('passport-github').Strategy; const passport = require('passport'); const User = require('../models/User'); -passport.use(new GitHubStrategy({ - clientID: process.env.GITHUB_CLIENT_ID, - clientSecret: process.env.GITHUB_CLIENT_SECRET, - callbackURL: "http://localhost:3000/auth/github/callback" -}, -function(accessToken, refreshToken, profile, cb) { - User.findOne({ githubId: profile.id }) - .then(user => { - console.log(profile); - if (user) return cb(null, user); - return User.create( - { - githubId: profile.id, - username: profile.login, - profileImg: profile.avatar_url, +// passport.use(new GitHubStrategy({ +// clientID: process.env.GITHUB_CLIENT_ID, +// clientSecret: process.env.GITHUB_CLIENT_SECRET, +// callbackURL: "http://localhost:3000/auth/github/callback" +// }, +// function(accessToken, refreshToken, profile, cb) { +// User.findOne({ githubId: profile.id }) +// .then(user => { +// if (user) return cb(null, user); +// return User.create( +// { +// githubId: profile.id, +// username: profile.login, +// profileImg: profile.avatar_url, - }).then(newUser => { - return cb(null, newUser); - }); - }) - .catch(err => { - cb(err); - }); -} -)); - - - -//github profile: -// { login: 'Cule219', -// id: 14827650, -// node_id: 'MDQ6VXNlcjE0ODI3NjUw', -// avatar_url: 'https://avatars3.githubusercontent.com/u/14827650?v=4', -// gravatar_id: '', -// url: 'https://api.github.com/users/Cule219', -// html_url: 'https://github.com/Cule219', -// followers_url: 'https://api.github.com/users/Cule219/followers', -// following_url: -// 'https://api.github.com/users/Cule219/following{/other_user}', -// gists_url: 'https://api.github.com/users/Cule219/gists{/gist_id}', -// starred_url: -// 'https://api.github.com/users/Cule219/starred{/owner}{/repo}', -// subscriptions_url: 'https://api.github.com/users/Cule219/subscriptions', -// organizations_url: 'https://api.github.com/users/Cule219/orgs', -// repos_url: 'https://api.github.com/users/Cule219/repos', -// events_url: 'https://api.github.com/users/Cule219/events{/privacy}', -// received_events_url: 'https://api.github.com/users/Cule219/received_events', -// type: 'User', -// site_admin: false, -// name: 'Stefan', -// company: null, -// blog: '', -// location: null, -// email: null, -// hireable: null, -// bio: null, -// public_repos: 59, -// public_gists: 0, -// followers: 0, -// following: 0, -// created_at: '2015-09-24T20:25:18Z', -// updated_at: '2019-06-19T13:43:44Z' } } \ No newline at end of file +// }).then(newUser => { +// return cb(null, newUser); +// }); +// }) +// .catch(err => { +// cb(err); +// }); +// } +// )); diff --git a/routes/homepages.js b/routes/homepages.js index 7fc8c00..acee9d1 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -2,7 +2,6 @@ const express = require('express'); const router = express.Router(); const Source = require('../models/Source'); const Article = require('../models/Article'); -const mongoose = require('mongoose'); router.get('/homepages/sources', (req, res) => { Source.find({}).then(data => { @@ -12,10 +11,9 @@ router.get('/homepages/sources', (req, res) => { router.get('/article/:articleId', (req, res, next) => { let liked = false; - Article.findOne({'_id': req.params.articleId }, (err, doc)=>{ - if(err)console.log(err); - if(doc.ratings.indexOf(req.user._id) !== -1)liked=true; - }).populate({path: 'comments', populate: {path: 'author'}}).then(article =>{ + Article.findOne({'_id': req.params.articleId }).populate({ + path: 'comments', populate: {path: 'author'}}).then(article =>{ + if(article.ratings.indexOf(req.user._id) !== -1)liked=true article.title = article.title.substring(0, article.title.lastIndexOf('-')); article.publishDate = article.publishedAt.toDateString(); Source.findOne({ 'id': article.source.id }).then(source => { diff --git a/routes/profiles.js b/routes/profiles.js index bba97b2..7b9abec 100644 --- a/routes/profiles.js +++ b/routes/profiles.js @@ -17,9 +17,7 @@ router.get('/source/:id', (req, res) => { router.get('/source/:id/edit', (req, res) => { Source.findOne({ 'id': req.params.id }).then(data => { Articles.find({'source.id': req.params.id}).then(articles => { - console.log('Before: ' + articles) articles = articles.splice(0, 2) - console.log('After : ' + articles) res.render('profile/editSource', { data, articles, user: req.user }); }); }).catch(err => console.log(err)) @@ -45,8 +43,7 @@ router.post('/source/:id', (req, res) => { router.get('/user/:id',(req, res) => { - console.log('ID: ' + req.params.id) - User.findById({_id: req.params.id}).then(data => { + User.findById({_id: req.params.id}).populate("comments").then(data => { let user = false; if(req.params.id == req.user._id) user = true; res.render('profile/user', {data, user: req.user}); }); From 27958f430f2d0a225f959ca68e229d460bb02482 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 10:18:00 +0200 Subject: [PATCH 04/40] profile recent comments added-not styled --- public/javascripts/script.js | 1 - routes/homepages.js | 2 +- routes/profiles.js | 16 ++++++++++------ routes/protected.js | 12 ++++++------ views/homepages/article.hbs | 4 ++++ views/profile/editUser.hbs | 6 ++++-- views/profile/user.hbs | 6 ++++-- 7 files changed, 29 insertions(+), 18 deletions(-) diff --git a/public/javascripts/script.js b/public/javascripts/script.js index f2bc97d..a8592d2 100644 --- a/public/javascripts/script.js +++ b/public/javascripts/script.js @@ -66,7 +66,6 @@ if(likeButton != undefined){ if(data.data.liked)likeButton.innerHTML="Unlike"; else{likeButton.innerHTML="Like"} }) - // location.reload(); }) } diff --git a/routes/homepages.js b/routes/homepages.js index acee9d1..8a527b0 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -13,7 +13,7 @@ router.get('/article/:articleId', (req, res, next) => { let liked = false; Article.findOne({'_id': req.params.articleId }).populate({ path: 'comments', populate: {path: 'author'}}).then(article =>{ - if(article.ratings.indexOf(req.user._id) !== -1)liked=true + if(req.user !== undefined)if(article.ratings.indexOf(req.user._id) !== -1)liked=true article.title = article.title.substring(0, article.title.lastIndexOf('-')); article.publishDate = article.publishedAt.toDateString(); Source.findOne({ 'id': article.source.id }).then(source => { diff --git a/routes/profiles.js b/routes/profiles.js index 7b9abec..4c480cd 100644 --- a/routes/profiles.js +++ b/routes/profiles.js @@ -43,17 +43,21 @@ router.post('/source/:id', (req, res) => { router.get('/user/:id',(req, res) => { - User.findById({_id: req.params.id}).populate("comments").then(data => { - let user = false; if(req.params.id == req.user._id) user = true; - res.render('profile/user', {data, user: req.user}); + User.findById({_id: req.params.id}) + .populate({path: "comments", populate: {path: 'author'}}).then( + data => { + userComments = data.comments.slice(0,2); + res.render('profile/user', {data,userComments, user: req.user}); }); }) router.get('/user/:id/edit', (req, res) => { - User.findById({_id: req.params.id}).then(data => { - let user = false; if(req.params.id == req.user._id) user = true; + User.findById({_id: req.params.id}) + .populate({path: "comments", populate: {path: 'author'}}).then( + data => { data.username = data.username.trim() - res.render('profile/editUser', {data, user: req.user}); + userComments = data.comments.slice(0,2); + res.render('profile/editUser', {data,userComments, user: req.user}); }); }) diff --git a/routes/protected.js b/routes/protected.js index 27da6bb..fe0c054 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -1,5 +1,4 @@ const express = require("express"); -const passport = require('passport'); const router = express.Router(); const User = require("../models/User"); const Comment = require('../models/Comment'); @@ -87,18 +86,19 @@ router.post('/comment', (req, res, next) => { rating: 0 }).then(data => { //this needs to be done with post middleware + User.findByIdAndUpdate(userId, + {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) + .then(data => console.log(data)); Article.findByIdAndUpdate( mongoose.Types.ObjectId(articleId), - {$push: {'comments': mongoose.Types.ObjectId(data._id)} - }).then(data => console.log(data.length)); + {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) + .then(data => console.log(data.length)); User.find({_id: userId}).then(user=>{ res.status(200).send({data, user}); - }); + }) }).catch( err =>console.log(err)); }); - - module.exports = router; diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index e99f217..9a74a40 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -4,7 +4,9 @@

Source reputation: {{source.reputation}}

+ {{#if user}} + {{/if}}

{{article.publishDate}}

@@ -64,7 +66,9 @@

{{this.author.username}}

{{this.content}}

Rating: {{this.rating}}

+ {{#if user}} + {{/if}} {{/each}} diff --git a/views/profile/editUser.hbs b/views/profile/editUser.hbs index 36eb6cd..819e170 100644 --- a/views/profile/editUser.hbs +++ b/views/profile/editUser.hbs @@ -35,8 +35,11 @@ - +

Recent Comments

+ {{#each userComments}} + {{this}} + {{/each}}
@@ -44,7 +47,6 @@

Rating: 3.4

- diff --git a/views/profile/user.hbs b/views/profile/user.hbs index 9793df1..0ec41a8 100644 --- a/views/profile/user.hbs +++ b/views/profile/user.hbs @@ -29,14 +29,16 @@ --}}

Recent Comments

-
+ {{#each userComments}} + {{this}} + {{/each}} +

Venezuela opposition to resume Norway-backed talks

Rating: 3.4

-
From fec8d0b391b31f550aaf26362c486d3ab35b5606 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 10:37:56 +0200 Subject: [PATCH 05/40] a --- models/Source.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/models/Source.js b/models/Source.js index f3f829a..5cc6af5 100644 --- a/models/Source.js +++ b/models/Source.js @@ -16,10 +16,6 @@ const sourceSchema = new Schema({ }, country: { type: String - // enum: ["ae", "ar", "at", "au", "be", "bg", "br", "ca", "ch", "cn", "co", "cu", - // "cz", "de", "eg", "fr", "gb", "gr", "hk", "hu", "id", "ie", "il", "in", "it", - // "jp", "kr", "lt", "lv", "ma", "mx", "my", "ng", "nl", "no", "nz", "ph", "pl", - // "pt", "ro", "rs", "ru", "sa", "se", "sg", "si", "sk", "th", "tr", "tw", "ua", "us", "ve", "za"] // "pk" "es" }, reputation: { type: Number, From f1748a8eda2a0a1030583f3b15dd837ede920db3 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 11:30:45 +0200 Subject: [PATCH 06/40] added about page and further DB seeding --- bin/seeds.js | 52 ++++++++++++++++++++- public/stylesheets/style.scss | 3 +- routes/homepages.js | 6 ++- routes/index.js | 4 -- views/{homepage.hbs => homepages/about.hbs} | 0 views/homepages/article.hbs | 4 ++ views/layout.hbs | 1 + 7 files changed, 63 insertions(+), 7 deletions(-) rename views/{homepage.hbs => homepages/about.hbs} (100%) diff --git a/bin/seeds.js b/bin/seeds.js index 0456a18..3b08a90 100644 --- a/bin/seeds.js +++ b/bin/seeds.js @@ -147,11 +147,60 @@ let sources = [ reputation: 112, comments: [], profileImg: `https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/CNBC_logo.svg/701px-CNBC_logo.svg.png`, - politicalBias: "CNN is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", + politicalBias: "CNBC is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", fundingSources: [ 'Advertising Revenue: $89 million - Source: CNN Income Report 2018', 'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018' ]}, + { + id: "nbc", + name: "NBC", + description: "NBC, the National Broadcasting Company, is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. NBC is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna. Praesent vitae justo at ipsum rutrum cursus. Mauris auctor a odio nec ullamcorper.", + url: "www.cnbc.com", + category: "general", + language: "en", + country: "us", + reputation: 112, + comments: [], + profileImg: `https://i0.wp.com/www.icingsmiles.org/wp-content/uploads/2015/09/NBC-Logo.png?ssl=1`, + politicalBias: "NBC is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna. Praesent vitae justo at ipsum rutrum cursus. Mauris auctor a odio nec ullamcorper.", + fundingSources: [ + 'Advertising Revenue: $89 million - Source: CNN Income Report 2018', + 'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018' + ]}, + { + id: "fox-news", + name: "Fox News", + description: "Fox News is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Fox News is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna. Praesent vitae justo at ipsum rutrum cursus. Mauris auctor a odio nec ullamcorper.", + url: "www.fox-news.com", + category: "general", + language: "en", + country: "us", + reputation: 112, + comments: [], + profileImg: `https://en.wikipedia.org/wiki/Fox_News#/media/File:Fox_News_Channel_logo.svg`, + politicalBias: "Fox News is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna.", + fundingSources: [ + 'Advertising Revenue: $89 million - Source: CNN Income Report 2018', + 'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018' + ]}, + { + id: "wired", + name: "Wired", + description: "Wired is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Wired is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna.", + url: "www.wired.com", + category: "general", + language: "en", + country: "us", + reputation: 112, + comments: [], + profileImg: `https://www.nowsecure.com/wp-content/uploads/2017/02/wired-uk-logo.png`, + politicalBias: "Wired is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna. Praesent vitae justo at ipsum rutrum cursus. Mauris auctor a odio nec ullamcorper. Proin hendrerit scelerisque condimentum.", + fundingSources: [ + 'Advertising Revenue: $89 million - Source: CNN Income Report 2018', + 'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018' + ]} + ]; let userId; User.find({}).then(data => userId = data[0]._id).catch(err=>console.log(err)); @@ -218,6 +267,7 @@ const seedAPI = () => { .then(data => console.log(data.length)).catch(err=>console.log(err)); }) .then(() => { + console.log('Successful DB seed') // Close properly the connection to Mongoose // mongoose.disconnect() }) diff --git a/public/stylesheets/style.scss b/public/stylesheets/style.scss index 8bdf149..e92402d 100644 --- a/public/stylesheets/style.scss +++ b/public/stylesheets/style.scss @@ -678,4 +678,5 @@ textarea { .recent-articles-img-container img { width: 100%; height: auto; -} \ No newline at end of file +} + diff --git a/routes/homepages.js b/routes/homepages.js index 99467bf..a66ab0b 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -10,11 +10,15 @@ router.get('/homepages/sources', (req, res) => { }).catch(err => console.log(err)); }) +router.get('/about', (req, res) => { + res.render('homepages/about') +}) + router.get('/article/:articleId', (req, res, next) => { let liked = false; Article.findOne({'_id': req.params.articleId }, (err, doc)=>{ if(err)console.log(err); - if(doc.ratings.indexOf(req.user._id) != -1)liked=true; + if(req.user && doc.ratings.indexOf(req.user._id) != -1)liked=true; }).populate({path: 'comments', populate: {path: 'author'}}).then(article =>{ article.title = article.title.substring(0, article.title.lastIndexOf('-')); article.publishDate = article.publishedAt.toDateString(); diff --git a/routes/index.js b/routes/index.js index 77072c9..33a0f70 100644 --- a/routes/index.js +++ b/routes/index.js @@ -14,9 +14,5 @@ router.get('/', (req, res, next) => { }).catch(err=>console.log(err)); }); - router.get('/welcome', (req, res) => { - res.render('homepage') - }) - module.exports = router; diff --git a/views/homepage.hbs b/views/homepages/about.hbs similarity index 100% rename from views/homepage.hbs rename to views/homepages/about.hbs diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index 6fc346b..6239163 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -4,7 +4,11 @@

Source reputation: {{source.reputation}}

+ {{#if user}} + {{else}} + + {{/if}}

{{article.publishDate}}

diff --git a/views/layout.hbs b/views/layout.hbs index 736f309..9f8376a 100644 --- a/views/layout.hbs +++ b/views/layout.hbs @@ -20,6 +20,7 @@ ×
Home + About All Sources {{#if user}} Profile From 5a2c58f7c3e9ffc77a64ac8ec57f8708a2580c9a Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 11:40:15 +0200 Subject: [PATCH 07/40] DB disconnect after seed --- bin/seeds.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/seeds.js b/bin/seeds.js index 7f53e0f..d5bc0aa 100644 --- a/bin/seeds.js +++ b/bin/seeds.js @@ -249,7 +249,10 @@ const seedAPI = () => { }); } -seedAPI(); +seedAPI() +setTimeout(() => { + mongoose.disconnect() +}, 5000) module.exports; From d27ab05cd822bfcb3c5683fe3f56dc40a8f3c6ac Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 11:48:51 +0200 Subject: [PATCH 08/40] reverted changes --- bin/seeds.js | 52 +-------------------- public/stylesheets/style.scss | 3 +- routes/homepages.js | 12 ++--- routes/index.js | 4 ++ views/{homepages/about.hbs => homepage.hbs} | 0 views/homepages/article.hbs | 6 +-- views/layout.hbs | 1 - 7 files changed, 13 insertions(+), 65 deletions(-) rename views/{homepages/about.hbs => homepage.hbs} (100%) diff --git a/bin/seeds.js b/bin/seeds.js index d5bc0aa..189c3a2 100644 --- a/bin/seeds.js +++ b/bin/seeds.js @@ -146,60 +146,11 @@ let sources = [ reputation: 112, comments: [], profileImg: `https://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/CNBC_logo.svg/701px-CNBC_logo.svg.png`, - politicalBias: "CNBC is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", + politicalBias: "CNN is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", fundingSources: [ 'Advertising Revenue: $89 million - Source: CNN Income Report 2018', 'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018' ]}, - { - id: "nbc", - name: "NBC", - description: "NBC, the National Broadcasting Company, is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. NBC is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna. Praesent vitae justo at ipsum rutrum cursus. Mauris auctor a odio nec ullamcorper.", - url: "www.cnbc.com", - category: "general", - language: "en", - country: "us", - reputation: 112, - comments: [], - profileImg: `https://i0.wp.com/www.icingsmiles.org/wp-content/uploads/2015/09/NBC-Logo.png?ssl=1`, - politicalBias: "NBC is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna. Praesent vitae justo at ipsum rutrum cursus. Mauris auctor a odio nec ullamcorper.", - fundingSources: [ - 'Advertising Revenue: $89 million - Source: CNN Income Report 2018', - 'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018' - ]}, - { - id: "fox-news", - name: "Fox News", - description: "Fox News is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Fox News is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna. Praesent vitae justo at ipsum rutrum cursus. Mauris auctor a odio nec ullamcorper.", - url: "www.fox-news.com", - category: "general", - language: "en", - country: "us", - reputation: 112, - comments: [], - profileImg: `https://en.wikipedia.org/wiki/Fox_News#/media/File:Fox_News_Channel_logo.svg`, - politicalBias: "Fox News is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna.", - fundingSources: [ - 'Advertising Revenue: $89 million - Source: CNN Income Report 2018', - 'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018' - ]}, - { - id: "wired", - name: "Wired", - description: "Wired is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Wired is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna.", - url: "www.wired.com", - category: "general", - language: "en", - country: "us", - reputation: 112, - comments: [], - profileImg: `https://www.nowsecure.com/wp-content/uploads/2017/02/wired-uk-logo.png`, - politicalBias: "Wired is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, CNN holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut non enim vehicula, suscipit neque et, viverra mi. Vivamus at justo urna. Praesent vitae justo at ipsum rutrum cursus. Mauris auctor a odio nec ullamcorper. Proin hendrerit scelerisque condimentum.", - fundingSources: [ - 'Advertising Revenue: $89 million - Source: CNN Income Report 2018', - 'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018' - ]} - ]; @@ -239,7 +190,6 @@ const seedAPI = () => { .then(data => console.log(data.length)).catch(err=>console.log(err)); }) .then(() => { - console.log('Successful DB seed') // Close properly the connection to Mongoose // mongoose.disconnect() }) diff --git a/public/stylesheets/style.scss b/public/stylesheets/style.scss index e92402d..8bdf149 100644 --- a/public/stylesheets/style.scss +++ b/public/stylesheets/style.scss @@ -678,5 +678,4 @@ textarea { .recent-articles-img-container img { width: 100%; height: auto; -} - +} \ No newline at end of file diff --git a/routes/homepages.js b/routes/homepages.js index 38042af..6c6101a 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -9,14 +9,12 @@ router.get('/homepages/sources', (req, res) => { }).catch(err => console.log(err)); }) - router.get('/article/:articleId', (req, res, next) => { - Article.findOne({'_id': req.params.articleId }).populate({ - path: 'comments', populate: {path: 'author'}}).then(article =>{ - let liked; - if(req.user !== undefined) { - liked = article.ratings.indexOf(req.user._id) !== -1 - } + let liked = false; + Article.findOne({'_id': req.params.articleId }, (err, doc)=>{ + if(err)console.log(err); + if(doc.ratings.indexOf(req.user._id) != -1)liked=true; + }).populate({path: 'comments', populate: {path: 'author'}}).then(article =>{ article.title = article.title.substring(0, article.title.lastIndexOf('-')); article.publishDate = article.publishedAt.toDateString(); Source.findOne({ 'id': article.source.id }).then(source => { diff --git a/routes/index.js b/routes/index.js index 33a0f70..77072c9 100644 --- a/routes/index.js +++ b/routes/index.js @@ -14,5 +14,9 @@ router.get('/', (req, res, next) => { }).catch(err=>console.log(err)); }); + router.get('/welcome', (req, res) => { + res.render('homepage') + }) + module.exports = router; diff --git a/views/homepages/about.hbs b/views/homepage.hbs similarity index 100% rename from views/homepages/about.hbs rename to views/homepage.hbs diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index 9a74a40..b59c889 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -3,10 +3,8 @@

{{article.source.name}}

-

Source reputation: {{source.reputation}}

- {{#if user}} - - {{/if}} +

Source reputation: {{source.reputation}}

+

{{article.publishDate}}

diff --git a/views/layout.hbs b/views/layout.hbs index 87c47ed..b6373fa 100644 --- a/views/layout.hbs +++ b/views/layout.hbs @@ -20,7 +20,6 @@ ×
Home - About All Sources {{#if user}} Profile From cedf1f66b35a1bafc66c5fd6f5ec902485dbf809 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 11:52:22 +0200 Subject: [PATCH 09/40] push for restore --- models/Comment.js | 10 ++--- routes/protected.js | 86 +++++++++++++++++++++---------------- views/homepages/article.hbs | 4 +- 3 files changed, 57 insertions(+), 43 deletions(-) diff --git a/models/Comment.js b/models/Comment.js index 77320c5..f327d51 100644 --- a/models/Comment.js +++ b/models/Comment.js @@ -21,11 +21,6 @@ const commentSchema = Schema({ user: { type: Schema.Types.ObjectId, ref: "User" - } -}, { - timestamps: { - createdAt: 'created_at', - updatedAt: 'updated_at' }, rating: { type: Number, @@ -35,6 +30,11 @@ const commentSchema = Schema({ type: Schema.Types.ObjectId, ref: "User" }] +}, { + timestamps: { + createdAt: 'created_at', + updatedAt: 'updated_at' + } }); module.exports = mongoose.model('Comment', commentSchema); \ No newline at end of file diff --git a/routes/protected.js b/routes/protected.js index fe0c054..397eb37 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -25,23 +25,6 @@ const loginCheck = () => { }; router.use(loginCheck()); -try{ -router.patch('/comment', async (req, res, next)=>{ - let userId = req.session.passport.user; - const doc = await Comment.findOne({'_id': req.body.commentId}); - console.log(doc.toObject().ratings) - if(doc.toObject().ratings.indexOf(userId) === -1){ - doc.toObject().ratings.push(userId); - doc.toObject().rating++; - }else{ - doc.toObject().ratings.pull(mongoose.Types.ObjectId(userId)); - doc.toObject().rating--; - } - doc.save(doc).then(data => {res.send({rating: data.rating, liked: data.toObject().ratings.includes(req.session.passport.user)}); - }) - }); -}catch(err){console.log(err)} - //use /\w+/ regex match here router.patch('/article', (req, res, next)=>{ let articleId = req.headers.referer.match(/[^\/]\w*$/)[0]; @@ -78,27 +61,58 @@ router.patch('/article', (req, res, next)=>{ router.post('/comment', (req, res, next) => { let articleId = req.headers.referer.match(/[^\/]\w*$/)[0]; let userId = req.session.passport.user - Comment.create({ - content: req.body.comment, - author: userId, - article: mongoose.Types.ObjectId(articleId), - ratings: [], - rating: 0 - }).then(data => { - //this needs to be done with post middleware - User.findByIdAndUpdate(userId, - {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) - .then(data => console.log(data)); - Article.findByIdAndUpdate( - mongoose.Types.ObjectId(articleId), - {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) - .then(data => console.log(data.length)); - User.find({_id: userId}).then(user=>{ - res.status(200).send({data, user}); + Comment.findOne({'_id': req.body.commentId}, (err, doc)=> { + if(err)console.log(err); + if(doc.ratings.indexOf(userId) === -1) + { + doc.ratings.push(userId); + doc.rating++; + }else{ + doc.ratings.pull(mongoose.Types.ObjectId(userId)); + doc.rating--; + } + doc.save(doc).then(data => { + User.findByIdAndUpdate(data.author, {$inc: {reputation: 1}}); }) -}).catch( - err =>console.log(err)); + }).catch(err =>console.log(err));; +}) + +router.patch('/comment', async (req, res, next)=>{ + const userId = req.session.passport.user; + Comment.findOne({'_id': req.body.commentId}, (err, doc)=> { + let docObject = doc._doc; + if(docObject.ratings === undefined) {docObject.ratings = []; docObject.rating = 0} + if(docObject.ratings.indexOf(userId) === -1){ + docObject.ratings.push(userId); + docObject.rating++; + }else{ + docObject.ratings.pull(mongoose.Types.ObjectId(userId)); + docObject.rating--; + } + Comment.findByIdAndUpdate(docObject._id ,{docObject}).then(data =>{ + res.send({rating: docObject.rating, liked: docObject.ratings.includes(req.session.passport.user)}); + }); + }).catch(err => console.log(err)); }); module.exports = router; + + +// router.patch('/comment', async (req, res, next)=>{ +// const userId = req.session.passport.user; +// Comment.findOne({'_id': req.body.commentId}, (err, doc)=> { +// let docObject = doc._doc; +// if(docObject.ratings === undefined) {docObject.ratings = []; docObject.rating = 0} +// if(docObject.ratings.indexOf(userId) === -1){ +// docObject.ratings.push(userId); +// docObject.rating++; +// }else{ +// docObject.ratings.pull(mongoose.Types.ObjectId(userId)); +// docObject.rating--; +// } +// Comment.findByIdAndUpdate(docObject._id ,{docObject}).then(data =>{ +// res.send({rating: docObject.rating, liked: docObject.ratings.includes(req.session.passport.user)}); +// }); +// }).catch(err => console.log(err)); +// }); diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index 9a74a40..534560f 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -66,9 +66,9 @@

{{this.author.username}}

{{this.content}}

Rating: {{this.rating}}

- {{#if user}} + {{!-- {{#if user}} --}} - {{/if}} + {{!-- {{/if}} --}}
{{/each}} From bfe4db1c784279a4b4c923bfdfa487f3ac589d1e Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 12:05:23 +0200 Subject: [PATCH 10/40] homepage addition --- routes/homepages.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/homepages.js b/routes/homepages.js index 6c6101a..596e532 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -13,7 +13,7 @@ router.get('/article/:articleId', (req, res, next) => { let liked = false; Article.findOne({'_id': req.params.articleId }, (err, doc)=>{ if(err)console.log(err); - if(doc.ratings.indexOf(req.user._id) != -1)liked=true; + if(req.user._id && doc.ratings.indexOf(req.user._id) != -1)liked=true; }).populate({path: 'comments', populate: {path: 'author'}}).then(article =>{ article.title = article.title.substring(0, article.title.lastIndexOf('-')); article.publishDate = article.publishedAt.toDateString(); From 0229d1c1232d721fd682a924345687750b28ab48 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 12:15:06 +0200 Subject: [PATCH 11/40] commit before change to master --- routes/protected.js | 84 ++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/routes/protected.js b/routes/protected.js index 397eb37..e8ade66 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -61,21 +61,27 @@ router.patch('/article', (req, res, next)=>{ router.post('/comment', (req, res, next) => { let articleId = req.headers.referer.match(/[^\/]\w*$/)[0]; let userId = req.session.passport.user - Comment.findOne({'_id': req.body.commentId}, (err, doc)=> { - if(err)console.log(err); - if(doc.ratings.indexOf(userId) === -1) - { - doc.ratings.push(userId); - doc.rating++; - }else{ - doc.ratings.pull(mongoose.Types.ObjectId(userId)); - doc.rating--; - } - doc.save(doc).then(data => { - User.findByIdAndUpdate(data.author, {$inc: {reputation: 1}}); + Comment.create({ + content: req.body.comment, + author: userId, + article: mongoose.Types.ObjectId(articleId), + ratings: [], + rating: 0 + }).then(data => { + //this needs to be done with post middleware + User.findByIdAndUpdate(userId, + {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) + .then(data => console.log(data)); + Article.findByIdAndUpdate( + mongoose.Types.ObjectId(articleId), + {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) + .then(data => console.log(data.length)); + User.find({_id: userId}).then(user=>{ + res.status(200).send({data, user}); }) - }).catch(err =>console.log(err));; -}) +}).catch( + err =>console.log(err)); +}); router.patch('/comment', async (req, res, next)=>{ const userId = req.session.passport.user; @@ -89,30 +95,36 @@ router.patch('/comment', async (req, res, next)=>{ docObject.ratings.pull(mongoose.Types.ObjectId(userId)); docObject.rating--; } - Comment.findByIdAndUpdate(docObject._id ,{docObject}).then(data =>{ - res.send({rating: docObject.rating, liked: docObject.ratings.includes(req.session.passport.user)}); - }); + doc.save(doc).then(data => { + res.send({ + rating: data.rating, liked: data.toObject().ratings.includes(req.session.passport.user) + }); + }) }).catch(err => console.log(err)); }); - module.exports = router; - - -// router.patch('/comment', async (req, res, next)=>{ -// const userId = req.session.passport.user; -// Comment.findOne({'_id': req.body.commentId}, (err, doc)=> { -// let docObject = doc._doc; -// if(docObject.ratings === undefined) {docObject.ratings = []; docObject.rating = 0} -// if(docObject.ratings.indexOf(userId) === -1){ -// docObject.ratings.push(userId); -// docObject.rating++; -// }else{ -// docObject.ratings.pull(mongoose.Types.ObjectId(userId)); -// docObject.rating--; -// } -// Comment.findByIdAndUpdate(docObject._id ,{docObject}).then(data =>{ -// res.send({rating: docObject.rating, liked: docObject.ratings.includes(req.session.passport.user)}); -// }); -// }).catch(err => console.log(err)); +// router.post('/comment', (req, res, next) => { +// let articleId = req.headers.referer.match(/[^\/]\w*$/)[0]; +// let userId = req.session.passport.user +// Comment.create({ +// content: req.body.comment, +// author: userId, +// article: mongoose.Types.ObjectId(articleId), +// ratings: [], +// rating: 0 +// }).then(data => { +// //this needs to be done with post middleware +// User.findByIdAndUpdate(userId, +// {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) +// .then(data => console.log(data)); +// Article.findByIdAndUpdate( +// mongoose.Types.ObjectId(articleId), +// {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) +// .then(data => console.log(data.length)); +// User.find({_id: userId}).then(user=>{ +// res.status(200).send({data, user}); +// }) +// }).catch( +// err =>console.log(err)); // }); From 3e6bbf9690d880566599535f339c723b7888ca7b Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 12:27:40 +0200 Subject: [PATCH 12/40] change --- routes/homepages.js | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/homepages.js b/routes/homepages.js index 9cc89e5..690d7d8 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -2,6 +2,7 @@ const express = require('express'); const router = express.Router(); const Source = require('../models/Source'); const Article = require('../models/Article'); +const User = require('../models/User') router.get('/homepages/sources', (req, res) => { Source.find({}).then(data => { From 677d2b078b7ad4951393cbeb56103ed036668523 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 12:47:32 +0200 Subject: [PATCH 13/40] updating social strategies --- passport/facebookStrategy.js | 2 +- passport/githubStrategy.js | 2 +- passport/googleStrategy.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/passport/facebookStrategy.js b/passport/facebookStrategy.js index 733c105..2e3f221 100644 --- a/passport/facebookStrategy.js +++ b/passport/facebookStrategy.js @@ -5,7 +5,7 @@ const User = require('../models/User'); passport.use(new FacebookStrategy({ clientID: process.env.FACEBOOK_USER_ID, clientSecret: process.env.FACEBOOK_KEY, - callbackURL: "http://localhost:3000/auth/facebook/callback" + callbackURL: "http://opinion-news.herokuapp.com/auth/facebook/callback" }, function(accessToken, refreshToken, profile, cb) { User.findOne({ facebookId: profile.id }).then(user => { diff --git a/passport/githubStrategy.js b/passport/githubStrategy.js index 7b5f352..780ae37 100644 --- a/passport/githubStrategy.js +++ b/passport/githubStrategy.js @@ -5,7 +5,7 @@ const User = require('../models/User'); passport.use(new GitHubStrategy({ clientID: process.env.GITHUB_CLIENT_ID, clientSecret: process.env.GITHUB_CLIENT_SECRET, - callbackURL: "http://localhost:3000/auth/github/callback" + callbackURL: "http://opinion-news.herokuapp.com/auth/github/callback" }, function(accessToken, refreshToken, profile, cb) { User.findOne({ githubId: profile.id }) diff --git a/passport/googleStrategy.js b/passport/googleStrategy.js index 09d5073..c1b1411 100644 --- a/passport/googleStrategy.js +++ b/passport/googleStrategy.js @@ -5,7 +5,7 @@ const User = require('../models/User'); passport.use(new GoogleStrategy({ clientID: process.env.GOOGLE_CLIENT_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, - callbackURL: "http://localhost:3000/auth/google/callback" + callbackURL: "http://opinion-news.herokuapp.com/auth/google/callback" }, function(accessToken, refreshToken, profile, cb) { User.findOne({ googleId: profile.id }) From c27d3e4236fc60bf2ec37e98aa04c7947133fe61 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 12:53:00 +0200 Subject: [PATCH 14/40] first article img error resolved --- routes/index.js | 1 + views/layout.hbs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/routes/index.js b/routes/index.js index e12a790..956c52b 100644 --- a/routes/index.js +++ b/routes/index.js @@ -9,6 +9,7 @@ router.get('/', (req, res, next) => { el.title = el.title.substring(0, el.title.lastIndexOf('-')) el.publishDate = el.publishedAt.toDateString() }) + if (data[0].source.name === 'Showbiz411.com') data.pop(); let first = data.pop(); res.render('index', {data, first, user: req.user}); }).catch(err=>console.log(err)); diff --git a/views/layout.hbs b/views/layout.hbs index 213b636..e037afe 100644 --- a/views/layout.hbs +++ b/views/layout.hbs @@ -31,12 +31,12 @@ {{/if}} - {{!-- From 7a7e392f8c29d0eb0c19f888bdf78903605fa20d Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 13:01:14 +0200 Subject: [PATCH 15/40] removed comments from profile --- views/profile/editUser.hbs | 12 ++---------- views/profile/user.hbs | 10 ++-------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/views/profile/editUser.hbs b/views/profile/editUser.hbs index 9a56308..f2e92cb 100644 --- a/views/profile/editUser.hbs +++ b/views/profile/editUser.hbs @@ -37,16 +37,8 @@

Recent Comments

- {{#each userComments}} - {{this}} - {{/each}} -
- -
-

Venezuela opposition to resume Norway-backed talks

-

Rating: 3.4

-
-
+ +

No recent comments

diff --git a/views/profile/user.hbs b/views/profile/user.hbs index 33d3997..d8d7be8 100644 --- a/views/profile/user.hbs +++ b/views/profile/user.hbs @@ -29,14 +29,8 @@ --}}

Recent Comments

- {{#each userComments}} - {{this}} - {{/each}} -
- -
-

Venezuela opposition to resume Norway-backed talks

-

Rating: 3.4

+ +

No recent comments

From 8b302cf96946521e74b712dd189f652f6c9acded Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 13:05:01 +0200 Subject: [PATCH 16/40] resolved first image not appearing --- routes/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/routes/index.js b/routes/index.js index 956c52b..8180118 100644 --- a/routes/index.js +++ b/routes/index.js @@ -9,7 +9,9 @@ router.get('/', (req, res, next) => { el.title = el.title.substring(0, el.title.lastIndexOf('-')) el.publishDate = el.publishedAt.toDateString() }) - if (data[0].source.name === 'Showbiz411.com') data.pop(); + if (data[data.length - 1].source.name === 'Showbiz411.com') { + data.pop(); + } let first = data.pop(); res.render('index', {data, first, user: req.user}); }).catch(err=>console.log(err)); From 5d8ac535e735071558560574c7fe77c56d81ca97 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 13:07:46 +0200 Subject: [PATCH 17/40] revert --- routes/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routes/index.js b/routes/index.js index 8180118..250d6dc 100644 --- a/routes/index.js +++ b/routes/index.js @@ -9,9 +9,9 @@ router.get('/', (req, res, next) => { el.title = el.title.substring(0, el.title.lastIndexOf('-')) el.publishDate = el.publishedAt.toDateString() }) - if (data[data.length - 1].source.name === 'Showbiz411.com') { - data.pop(); - } + // if (data[data.length - 1].source.name === 'Showbiz411.com') { + // data.pop(); + // } let first = data.pop(); res.render('index', {data, first, user: req.user}); }).catch(err=>console.log(err)); From e9cb8ce3405e87f0e526c38d252c88f8af08bbc6 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 13:10:39 +0200 Subject: [PATCH 18/40] reverting revert --- routes/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/routes/index.js b/routes/index.js index 250d6dc..1c3be2b 100644 --- a/routes/index.js +++ b/routes/index.js @@ -5,13 +5,15 @@ const Article = require('../models/Article'); /* GET home page */ router.get('/', (req, res, next) => { Article.find({}).then(data =>{ + + if (data[data.length - 1].source.name === 'Showbiz411.com') { + data.pop(); + } + data.forEach(el => { el.title = el.title.substring(0, el.title.lastIndexOf('-')) el.publishDate = el.publishedAt.toDateString() }) - // if (data[data.length - 1].source.name === 'Showbiz411.com') { - // data.pop(); - // } let first = data.pop(); res.render('index', {data, first, user: req.user}); }).catch(err=>console.log(err)); From 71caa51083150b37557290889ce5703274623b2e Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 13:11:32 +0200 Subject: [PATCH 19/40] fixing frontpage bug --- routes/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/routes/index.js b/routes/index.js index 1c3be2b..e1b98a4 100644 --- a/routes/index.js +++ b/routes/index.js @@ -5,10 +5,6 @@ const Article = require('../models/Article'); /* GET home page */ router.get('/', (req, res, next) => { Article.find({}).then(data =>{ - - if (data[data.length - 1].source.name === 'Showbiz411.com') { - data.pop(); - } data.forEach(el => { el.title = el.title.substring(0, el.title.lastIndexOf('-')) From 39259c5a7d1896fc4d72cee158e20751d707ef6c Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 13:17:03 +0200 Subject: [PATCH 20/40] praise be to hesus --- routes/homepages.js | 1 - 1 file changed, 1 deletion(-) diff --git a/routes/homepages.js b/routes/homepages.js index bfae684..65e77ed 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -2,7 +2,6 @@ const express = require('express'); const router = express.Router(); const Source = require('../models/Source'); const Article = require('../models/Article'); -const User = require('../models/User') router.get('/homepages/sources', (req, res) => { Source.find({}).then(data => { From a9408639dcabff66b959b061678cbb4a576a1fb5 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 13:19:19 +0200 Subject: [PATCH 21/40] praise be to hesus --- routes/homepages.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/homepages.js b/routes/homepages.js index 65e77ed..f12c7ad 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -10,9 +10,9 @@ router.get('/homepages/sources', (req, res) => { }) router.get('/article/:articleId', (req, res, next) => { + let liked = false; Article.findOne({'_id': req.params.articleId }).populate({ path: 'comments', populate: {path: 'author'}}).then(article =>{ - let liked = false; if(req.user != undefined)if(article.ratings.indexOf(req.user._id) !== -1)liked=true; article.title = article.title.substring(0, article.title.lastIndexOf('-')); article.publishDate = article.publishedAt.toDateString(); From 89331396561acff62e0a6200616f739f13483d57 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 13:34:31 +0200 Subject: [PATCH 22/40] added some changes --- routes/protected.js | 60 ++++++++++++++++++++++++++----------- views/homepages/article.hbs | 6 ++-- views/profile/editUser.hbs | 4 ++- views/profile/user.hbs | 5 ++-- 4 files changed, 53 insertions(+), 22 deletions(-) diff --git a/routes/protected.js b/routes/protected.js index e59e89c..2a106ae 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -25,23 +25,6 @@ const loginCheck = () => { }; router.use(loginCheck()); -try{ -router.patch('/comment', async (req, res, next)=>{ - let userId = req.session.passport.user; - const doc = await Comment.findOne({'_id': req.body.commentId}); - console.log(doc.toObject().ratings) - if(doc.toObject().ratings.indexOf(userId) === -1){ - doc.toObject().ratings.push(userId); - doc.toObject().rating++; - }else{ - doc.toObject().ratings.pull(mongoose.Types.ObjectId(userId)); - doc.toObject().rating--; - } - doc.save(doc).then(data => {res.send({rating: data.rating, liked: data.toObject().ratings.includes(req.session.passport.user)}); - }) - }); -}catch(err){console.log(err)} - //use /\w+/ regex match here router.patch('/article', (req, res, next)=>{ let articleId = req.headers.referer.match(/[^\/]\w*$/)[0]; @@ -101,5 +84,48 @@ router.post('/comment', (req, res, next) => { err =>console.log(err)); }); +router.patch('/comment', async (req, res, next)=>{ + const userId = req.session.passport.user; + Comment.findOne({'_id': req.body.commentId}, (err, doc)=> { + let docObject = doc._doc; + if(docObject.ratings === undefined) {docObject.ratings = []; docObject.rating = 0} + if(docObject.ratings.indexOf(userId) === -1){ + docObject.ratings.push(userId); + docObject.rating++; + }else{ + docObject.ratings.pull(mongoose.Types.ObjectId(userId)); + docObject.rating--; + } + doc.save(doc).then(data => { + res.send({ + rating: data.rating, liked: data.toObject().ratings.includes(req.session.passport.user) + }); + }) + }).catch(err => console.log(err)); +}); module.exports = router; +// router.post('/comment', (req, res, next) => { +// let articleId = req.headers.referer.match(/[^\/]\w*$/)[0]; +// let userId = req.session.passport.user +// Comment.create({ +// content: req.body.comment, +// author: userId, +// article: mongoose.Types.ObjectId(articleId), +// ratings: [], +// rating: 0 +// }).then(data => { +// //this needs to be done with post middleware +// User.findByIdAndUpdate(userId, +// {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) +// .then(data => console.log(data)); +// Article.findByIdAndUpdate( +// mongoose.Types.ObjectId(articleId), +// {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) +// .then(data => console.log(data.length)); +// User.find({_id: userId}).then(user=>{ +// res.status(200).send({data, user}); +// }) +// }).catch( +// err =>console.log(err)); +// }); diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index b59c889..9a74a40 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -3,8 +3,10 @@

{{article.source.name}}

-

Source reputation: {{source.reputation}}

- +

Source reputation: {{source.reputation}}

+ {{#if user}} + + {{/if}}

{{article.publishDate}}

diff --git a/views/profile/editUser.hbs b/views/profile/editUser.hbs index f2e92cb..91a27a9 100644 --- a/views/profile/editUser.hbs +++ b/views/profile/editUser.hbs @@ -37,7 +37,9 @@

Recent Comments

- + {{#each userComments}} + {{this}} + {{/each}}

No recent comments

diff --git a/views/profile/user.hbs b/views/profile/user.hbs index d8d7be8..724d76f 100644 --- a/views/profile/user.hbs +++ b/views/profile/user.hbs @@ -29,11 +29,12 @@ --}}

Recent Comments

- + {{#each userComments}} + {{this}} + {{/each}}

No recent comments

- From e883a9368fba6f9d661ae6aee68a1300c771a9ce Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 13:59:39 +0200 Subject: [PATCH 23/40] work --- passport/facebookStrategy.js | 25 +------------------------ passport/githubStrategy.js | 30 +----------------------------- passport/googleStrategy.js | 20 -------------------- routes/homepages.js | 4 ---- routes/protected.js | 3 --- 5 files changed, 2 insertions(+), 80 deletions(-) diff --git a/passport/facebookStrategy.js b/passport/facebookStrategy.js index f99c75c..e0a3395 100644 --- a/passport/facebookStrategy.js +++ b/passport/facebookStrategy.js @@ -2,11 +2,10 @@ const FacebookStrategy = require("passport-facebook").Strategy; const passport = require('passport'); const User = require('../models/User'); -<<<<<<< HEAD // passport.use(new FacebookStrategy({ // clientID: process.env.FACEBOOK_USER_ID, // clientSecret: process.env.FACEBOOK_KEY, -// callbackURL: "http://localhost:3000/auth/facebook/callback" +// callbackURL: "http://opinion-news.herokuapp.com/auth/facebook/callback" // }, // function(accessToken, refreshToken, profile, cb) { // User.findOne({ facebookId: profile.id }).then(user => { @@ -23,25 +22,3 @@ const User = require('../models/User'); // }); // } // )); -======= -passport.use(new FacebookStrategy({ - clientID: process.env.FACEBOOK_USER_ID, - clientSecret: process.env.FACEBOOK_KEY, - callbackURL: "http://opinion-news.herokuapp.com/auth/facebook/callback" - }, - function(accessToken, refreshToken, profile, cb) { - User.findOne({ facebookId: profile.id }).then(user => { - if (user) return cb(null, user); - console.log('FB user: ' + user) - return User.create({ - facebookId: profile.id, - fullName: profile.displayName - }).then(newUser => { - return cb(null, newUser); - }); - }).catch(err => { - cb(err); - }); - } -)); ->>>>>>> master diff --git a/passport/githubStrategy.js b/passport/githubStrategy.js index 721f627..e08bcb4 100644 --- a/passport/githubStrategy.js +++ b/passport/githubStrategy.js @@ -2,41 +2,14 @@ const GitHubStrategy = require('passport-github').Strategy; const passport = require('passport'); const User = require('../models/User'); -<<<<<<< HEAD -// passport.use(new GitHubStrategy({ -// clientID: process.env.GITHUB_CLIENT_ID, -// clientSecret: process.env.GITHUB_CLIENT_SECRET, -// callbackURL: "http://localhost:3000/auth/github/callback" -// }, -// function(accessToken, refreshToken, profile, cb) { -// User.findOne({ githubId: profile.id }) -// .then(user => { -// if (user) return cb(null, user); -// return User.create( -// { -// githubId: profile.id, -// username: profile.login, -// profileImg: profile.avatar_url, - -// }).then(newUser => { -// return cb(null, newUser); -// }); -// }) -// .catch(err => { -// cb(err); -// }); -// } -// )); -======= passport.use(new GitHubStrategy({ clientID: process.env.GITHUB_CLIENT_ID, clientSecret: process.env.GITHUB_CLIENT_SECRET, - callbackURL: "http://opinion-news.herokuapp.com/auth/github/callback" + callbackURL: "http://localhost:3000/auth/github/callback" }, function(accessToken, refreshToken, profile, cb) { User.findOne({ githubId: profile.id }) .then(user => { - console.log(profile); if (user) return cb(null, user); return User.create( { @@ -53,4 +26,3 @@ function(accessToken, refreshToken, profile, cb) { }); } )); ->>>>>>> master diff --git a/passport/googleStrategy.js b/passport/googleStrategy.js index c1b1411..9487f7c 100644 --- a/passport/googleStrategy.js +++ b/passport/googleStrategy.js @@ -25,23 +25,3 @@ function(accessToken, refreshToken, profile, cb) { }); } )); - -//Google profile examp: - -// { id: '112678934251205388903', -// displayName: 'Stefan Culafic', -// name: { familyName: 'Culafic', givenName: 'Stefan' }, -// photos: -// [ { value: -// 'https://lh3.googleusercontent.com/-vN2r6OL7IHg/AAAAAAAAAAI/AAAAAAAAHcs/e27OZ_SW810/photo.jpg' } ], -// provider: 'google', -// _raw: -// '{\n "sub": "112678934251205388903",\n "name": "Stefan Culafic",\n "given_name": "Stefan",\n "family_name": "Culafic",\n "picture": "https://lh3.googleusercontent.com/-vN2r6OL7IHg/AAAAAAAAAAI/AAAAAAAAHcs/e27OZ_SW810/photo.jpg",\n "locale": "en"\n}', -// _json: -// { sub: '112678934251205388903', -// name: 'Stefan Culafic', -// given_name: 'Stefan', -// family_name: 'Culafic', -// picture: -// 'https://lh3.googleusercontent.com/-vN2r6OL7IHg/AAAAAAAAAAI/AAAAAAAAHcs/e27OZ_SW810/photo.jpg', -// locale: 'en' } } \ No newline at end of file diff --git a/routes/homepages.js b/routes/homepages.js index ecb1069..f12c7ad 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -13,11 +13,7 @@ router.get('/article/:articleId', (req, res, next) => { let liked = false; Article.findOne({'_id': req.params.articleId }).populate({ path: 'comments', populate: {path: 'author'}}).then(article =>{ -<<<<<<< HEAD - if(req.user !== undefined)if(article.ratings.indexOf(req.user._id) !== -1)liked=true -======= if(req.user != undefined)if(article.ratings.indexOf(req.user._id) !== -1)liked=true; ->>>>>>> master article.title = article.title.substring(0, article.title.lastIndexOf('-')); article.publishDate = article.publishedAt.toDateString(); Source.findOne({ 'id': article.source.id }).then(source => { diff --git a/routes/protected.js b/routes/protected.js index 86a2264..2a106ae 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -84,7 +84,6 @@ router.post('/comment', (req, res, next) => { err =>console.log(err)); }); -<<<<<<< HEAD router.patch('/comment', async (req, res, next)=>{ const userId = req.session.passport.user; Comment.findOne({'_id': req.body.commentId}, (err, doc)=> { @@ -104,8 +103,6 @@ router.patch('/comment', async (req, res, next)=>{ }) }).catch(err => console.log(err)); }); -======= ->>>>>>> master module.exports = router; // router.post('/comment', (req, res, next) => { From 51cbf769fd2acea12340a677ede7bda92a5d3e85 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 14:13:07 +0200 Subject: [PATCH 24/40] commit --- routes/protected.js | 3 ++- views/homepages/article.hbs | 11 ----------- views/profile/editUser.hbs | 14 +------------- views/profile/user.hbs | 13 +------------ 4 files changed, 4 insertions(+), 37 deletions(-) diff --git a/routes/protected.js b/routes/protected.js index 2a106ae..4d970e3 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -96,10 +96,11 @@ router.patch('/comment', async (req, res, next)=>{ docObject.ratings.pull(mongoose.Types.ObjectId(userId)); docObject.rating--; } - doc.save(doc).then(data => { + Comment.findByIdAndUpdate(docObject._id, {docObject}).then(data => { res.send({ rating: data.rating, liked: data.toObject().ratings.includes(req.session.passport.user) }); + // doc.save(doc). }) }).catch(err => console.log(err)); }); diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index 6c805c6..534560f 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -3,15 +3,10 @@

{{article.source.name}}

-<<<<<<< HEAD

Source reputation: {{source.reputation}}

{{#if user}} {{/if}} -======= -

Source reputation: {{source.reputation}}

- ->>>>>>> master

{{article.publishDate}}

@@ -71,15 +66,9 @@

{{this.author.username}}

{{this.content}}

Rating: {{this.rating}}

-<<<<<<< HEAD {{!-- {{#if user}} --}} {{!-- {{/if}} --}} -======= - {{#if user}} - - {{/if}} ->>>>>>> master {{/each}} diff --git a/views/profile/editUser.hbs b/views/profile/editUser.hbs index 9935031..09d7209 100644 --- a/views/profile/editUser.hbs +++ b/views/profile/editUser.hbs @@ -37,22 +37,10 @@

Recent Comments

-<<<<<<< HEAD {{#each userComments}} {{this}} {{/each}} -
- -
-

Venezuela opposition to resume Norway-backed talks

-

Rating: 3.4

-
-
-======= - -

No recent comments

- ->>>>>>> master + diff --git a/views/profile/user.hbs b/views/profile/user.hbs index c3ac870..3f448e0 100644 --- a/views/profile/user.hbs +++ b/views/profile/user.hbs @@ -29,21 +29,10 @@ --}}

Recent Comments

-<<<<<<< HEAD {{#each userComments}} {{this}} {{/each}} -
- -
-

Venezuela opposition to resume Norway-backed talks

-

Rating: 3.4

-======= - -

No recent comments

->>>>>>> master -
-
+ From 7d3c51a8cc7a60b2b0b07b3ea0fa817bb9a99703 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 14:13:35 +0200 Subject: [PATCH 25/40] fix --- views/homepages/article.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index 9a74a40..534560f 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -66,9 +66,9 @@

{{this.author.username}}

{{this.content}}

Rating: {{this.rating}}

- {{#if user}} + {{!-- {{#if user}} --}} - {{/if}} + {{!-- {{/if}} --}} {{/each}} From 67b8d43137933af8ec3b09ecb45c8d763f3b5ed3 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 14:26:08 +0200 Subject: [PATCH 26/40] build out source seed file --- bin/seeds.js | 87 +++++++++++++++++++++++++++++++++++-- views/homepages/article.hbs | 2 +- 2 files changed, 85 insertions(+), 4 deletions(-) diff --git a/bin/seeds.js b/bin/seeds.js index 189c3a2..5145e1c 100644 --- a/bin/seeds.js +++ b/bin/seeds.js @@ -138,8 +138,8 @@ let sources = [ { id: "cnbc", name: "CNBC", - description: "CNBC, the Cable News Network, is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. CNBC is owned by NBC Universal Broadcast which is in turn owned by Comcast.", - url: "www.cnn.com", + description: "CNBC, the Cable News Network, is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. CNBC is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ", + url: "www.cnbc.com", category: "general", language: "en", country: "us", @@ -151,7 +151,87 @@ let sources = [ 'Advertising Revenue: $89 million - Source: CNN Income Report 2018', 'Cable Company Subscriptions: $75 million - Source: CNN Income Report 2018' ]}, - + { + id: "fox-news", + name: "Fox News", + description: "Fox News is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Fox News is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ", + url: "www.fox-news.com", + category: "general", + language: "en", + country: "us", + reputation: 174, + comments: [], + profileImg: `https://upload.wikimedia.org/wikipedia/commons/6/67/Fox_News_Channel_logo.svg`, + politicalBias: "Fox News is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, Fox News holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", + fundingSources: [ + 'Advertising Revenue: $89 million - Source: Fox News Income Report 2018', + 'Cable Company Subscriptions: $75 million - Source: Fox News Income Report 2018' + ]}, + { + id: "usa-today", + name: "USA Today", + description: "USA Today is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. USA Today is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ", + url: "www.usatoday.com", + category: "general", + language: "en", + country: "us", + reputation: 174, + comments: [], + profileImg: `https://upload.wikimedia.org/wikipedia/commons/6/67/Fox_News_Channel_logo.svg`, + politicalBias: "USA Today is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, USA Today holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", + fundingSources: [ + 'Advertising Revenue: $89 million - Source: USA Today Income Report 2018', + 'Cable Company Subscriptions: $75 million - Source: USA Today Income Report 2018' + ]}, + { + id: "nbc-news", + name: "NBC News", + description: "NBC News is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. NBC News is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ", + url: "www.nbc-news.com", + category: "general", + language: "en", + country: "us", + reputation: 174, + comments: [], + profileImg: `https://i0.wp.com/www.icingsmiles.org/wp-content/uploads/2015/09/NBC-Logo.png?ssl=1`, + politicalBias: "NBC News is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, NBC News holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", + fundingSources: [ + 'Advertising Revenue: $89 million - Source: NBC News Income Report 2018', + 'Cable Company Subscriptions: $75 million - Source: NBC News Income Report 2018' + ]}, + { + id: "politico", + name: "Politico", + description: "Politico is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Politico is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ", + url: "www.politico.com", + category: "general", + language: "en", + country: "us", + reputation: 174, + comments: [], + profileImg: `https://pmcvariety.files.wordpress.com/2016/05/politico-logo.jpg?w=913&h=513&crop=1`, + politicalBias: "Politico is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, Politico holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", + fundingSources: [ + 'Advertising Revenue: $89 million - Source: Politico Income Report 2018', + 'Cable Company Subscriptions: $75 million - Source: Politico Income Report 2018' + ]}, + { + id: "politico", + name: "Politico", + description: "Politico is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Politico is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ", + url: "www.politico.com", + category: "general", + language: "en", + country: "us", + reputation: 174, + comments: [], + profileImg: `https://pmcvariety.files.wordpress.com/2016/05/politico-logo.jpg?w=913&h=513&crop=1`, + politicalBias: "Politico is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, Politico holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", + fundingSources: [ + 'Advertising Revenue: $89 million - Source: Politico Income Report 2018', + 'Cable Company Subscriptions: $75 million - Source: Politico Income Report 2018' + ]}, + ]; User.deleteMany() @@ -190,6 +270,7 @@ const seedAPI = () => { .then(data => console.log(data.length)).catch(err=>console.log(err)); }) .then(() => { + console.log('sources successfully added') // Close properly the connection to Mongoose // mongoose.disconnect() }) diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index b59c889..69bc035 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -18,7 +18,7 @@

About this source...

{{#if user}} - + {{else}} {{/if}} From 5a95306ed1c35648c6acc6e6712a5a6eba9463f0 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 14:34:00 +0200 Subject: [PATCH 27/40] fixed usa-today logo --- bin/seeds.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/seeds.js b/bin/seeds.js index 5145e1c..a7f718c 100644 --- a/bin/seeds.js +++ b/bin/seeds.js @@ -177,7 +177,7 @@ let sources = [ country: "us", reputation: 174, comments: [], - profileImg: `https://upload.wikimedia.org/wikipedia/commons/6/67/Fox_News_Channel_logo.svg`, + profileImg: `https://en.wikipedia.org/wiki/USA_Today#/media/File:USA_Today_2012logo.svg`, politicalBias: "USA Today is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, USA Today holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", fundingSources: [ 'Advertising Revenue: $89 million - Source: USA Today Income Report 2018', From fde08cbb06f829e8227d83029ceba00d6c3fbe0e Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 12 Jul 2019 14:38:59 +0200 Subject: [PATCH 28/40] fix company logos --- bin/seeds.js | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/bin/seeds.js b/bin/seeds.js index a7f718c..ecf9b5e 100644 --- a/bin/seeds.js +++ b/bin/seeds.js @@ -177,7 +177,7 @@ let sources = [ country: "us", reputation: 174, comments: [], - profileImg: `https://en.wikipedia.org/wiki/USA_Today#/media/File:USA_Today_2012logo.svg`, + profileImg: `https://www.american.edu/uploads/standard/large/01_Primary_01_FullColor_USATODAY_Logo_Prm_FullClr_RGB_600copy.png`, politicalBias: "USA Today is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, USA Today holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", fundingSources: [ 'Advertising Revenue: $89 million - Source: USA Today Income Report 2018', @@ -214,23 +214,7 @@ let sources = [ fundingSources: [ 'Advertising Revenue: $89 million - Source: Politico Income Report 2018', 'Cable Company Subscriptions: $75 million - Source: Politico Income Report 2018' - ]}, - { - id: "politico", - name: "Politico", - description: "Politico is one of the most prominent names in the American national broadcasting sphere relating to the stock market and is known around the global. Politico is owned by NBC Universal Broadcast which is in turn owned by Comcast. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vel quam ac odio auctor laoreet sit amet in orci. Duis accumsan sed elit sed dictum. Curabitur convallis semper sapien nec iaculis. ", - url: "www.politico.com", - category: "general", - language: "en", - country: "us", - reputation: 174, - comments: [], - profileImg: `https://pmcvariety.files.wordpress.com/2016/05/politico-logo.jpg?w=913&h=513&crop=1`, - politicalBias: "Politico is one of America's leading media corporations and, as such, is suspecible to the ever pervading influence, and push and pull, of mainstream American politics. Traditionally, Politico holds a right of centre political stance. The broadcasting network's host of hosts and representatives deliberately reinforces this left leaning political stance to appease the viewing audience.", - fundingSources: [ - 'Advertising Revenue: $89 million - Source: Politico Income Report 2018', - 'Cable Company Subscriptions: $75 million - Source: Politico Income Report 2018' - ]}, + ]} ]; From 27211a6626d0e7de07ccb72a9ab33e67ee6a2988 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 14:43:41 +0200 Subject: [PATCH 29/40] last commit --- public/javascripts/script.js | 5 ++++- routes/protected.js | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/public/javascripts/script.js b/public/javascripts/script.js index a8592d2..bc4ad6f 100644 --- a/public/javascripts/script.js +++ b/public/javascripts/script.js @@ -44,6 +44,7 @@ const newComment = (data) => { let descriptionUser = document.createElement('p'); descriptionUser.innerHTML = data.data.data.content; let ratingUser = document.createElement('p'); + ratingUser.classList = data.data.user[0].username; ratingUser.innerHTML = `Rating: ${data.data.data.rating || 0}`; let likeButton = document.createElement('button'); likeButton.innerHTML = 'Like'; @@ -76,7 +77,9 @@ if(commentBox != undefined){ let username = e.target.parentNode.getElementsByTagName('h3')[0].innerHTML; let commentId = e.target.value; axios.patch(`${baseUrl}/comment`, {data: username, commentId: commentId}).then(data => { - document.getElementById('comment-rating').innerHTML = `Rating: ${data.data.rating}`; + document.getElementsByClassName('username').forEach(element => { + element.innerHTML = `Rating: ${data.data.rating}`; + }); if(data.data.liked)e.target.innerHTML="unlike"; else{e.target.innerHTML="like"} }) diff --git a/routes/protected.js b/routes/protected.js index 4d970e3..a133c8a 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -50,7 +50,6 @@ router.patch('/article', (req, res, next)=>{ doc.reputation--; } doc.save(doc).then(cont => { - console.log(data.ratings.includes(req.session.passport.user), req.session.passport.user) res.send({rating: cont.reputation, liked: data.ratings.includes(req.session.passport.user)}); }) if(err)console.log(err); @@ -96,7 +95,12 @@ router.patch('/comment', async (req, res, next)=>{ docObject.ratings.pull(mongoose.Types.ObjectId(userId)); docObject.rating--; } - Comment.findByIdAndUpdate(docObject._id, {docObject}).then(data => { + console.log(docObject); + Comment.findByIdAndUpdate(docObject._id, { + ratings: docObject.ratings, + rating: docObject.rating + }, { new: true }).then(data => { + console.log(data) res.send({ rating: data.rating, liked: data.toObject().ratings.includes(req.session.passport.user) }); From ed33e0d1f5c8eb6d10031628577298e0db579219 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 14:46:36 +0200 Subject: [PATCH 30/40] Lana is the greatest --- views/homepages/article.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index 534560f..975dcf0 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -58,7 +58,6 @@ > {{else}}

Login here to join the discussion.

- {{/if}} {{#each article.comments}}
@@ -72,6 +71,7 @@
{{/each}} + {{/if}} \ No newline at end of file From 4ba758df086d7147763fdf1b0173df2b14fad0f1 Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 12 Jul 2019 14:54:40 +0200 Subject: [PATCH 31/40] Update article.hbs --- views/homepages/article.hbs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index ce22295..fd3bad9 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -58,6 +58,8 @@ > {{else}}

Login here to join the discussion.

+ + {{/if}} {{#each article.comments}}
@@ -71,7 +73,6 @@
{{/each}} - {{/if}} - \ No newline at end of file + From c2a6704e456d4f7caac87befe176d7ab8ebe390e Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 18:45:29 +0200 Subject: [PATCH 32/40] fix --- passport/googleStrategy.js | 2 +- public/javascripts/script.js | 13 ++++++++----- routes/protected.js | 5 ++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/passport/googleStrategy.js b/passport/googleStrategy.js index 9487f7c..b047f5e 100644 --- a/passport/googleStrategy.js +++ b/passport/googleStrategy.js @@ -5,7 +5,7 @@ const User = require('../models/User'); passport.use(new GoogleStrategy({ clientID: process.env.GOOGLE_CLIENT_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, - callbackURL: "http://opinion-news.herokuapp.com/auth/google/callback" + callbackURL: "http://opinion-news.herokuapp.com/auth/google/callback"//http://localhost:3000 }, function(accessToken, refreshToken, profile, cb) { User.findOne({ googleId: profile.id }) diff --git a/public/javascripts/script.js b/public/javascripts/script.js index bc4ad6f..6eed201 100644 --- a/public/javascripts/script.js +++ b/public/javascripts/script.js @@ -75,13 +75,16 @@ if(commentBox != undefined){ commentBox.addEventListener('click', (e)=>{ if(e.target.className == 'like-button'){ let username = e.target.parentNode.getElementsByTagName('h3')[0].innerHTML; + let ratingElement = e.target.parentNode.getElementsByTagName('p')[1]; + console.log(ratingElement) let commentId = e.target.value; axios.patch(`${baseUrl}/comment`, {data: username, commentId: commentId}).then(data => { - document.getElementsByClassName('username').forEach(element => { - element.innerHTML = `Rating: ${data.data.rating}`; - }); - if(data.data.liked)e.target.innerHTML="unlike"; - else{e.target.innerHTML="like"} + // document.getElementsByClassName('username').forEach(element => { + // element.innerHTML = `Rating: ${data.data.rating}`; + // }); + ratingElement.innerHTML = `Rating: ${data.data.rating}`; + if(data.data.liked)e.target.innerHTML="Unlike"; + else{e.target.innerHTML="Like"} }) } }); diff --git a/routes/protected.js b/routes/protected.js index a133c8a..46a8547 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -95,14 +95,13 @@ router.patch('/comment', async (req, res, next)=>{ docObject.ratings.pull(mongoose.Types.ObjectId(userId)); docObject.rating--; } - console.log(docObject); Comment.findByIdAndUpdate(docObject._id, { ratings: docObject.ratings, rating: docObject.rating }, { new: true }).then(data => { - console.log(data) + console.log(docObject.ratings.includes(req.session.passport.user)); res.send({ - rating: data.rating, liked: data.toObject().ratings.includes(req.session.passport.user) + rating: data.rating, liked: docObject.ratings.includes(req.session.passport.user) }); // doc.save(doc). }) From e12890cedb5b0178e48a632505409b97565ebbb0 Mon Sep 17 00:00:00 2001 From: cule219 Date: Fri, 12 Jul 2019 18:50:13 +0200 Subject: [PATCH 33/40] fix --- public/javascripts/script.js | 11 ++++++++--- routes/protected.js | 26 +------------------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/public/javascripts/script.js b/public/javascripts/script.js index a8592d2..f1bfb79 100644 --- a/public/javascripts/script.js +++ b/public/javascripts/script.js @@ -74,11 +74,16 @@ if(commentBox != undefined){ commentBox.addEventListener('click', (e)=>{ if(e.target.className == 'like-button'){ let username = e.target.parentNode.getElementsByTagName('h3')[0].innerHTML; + let ratingElement = e.target.parentNode.getElementsByTagName('p')[1]; + console.log(ratingElement) let commentId = e.target.value; axios.patch(`${baseUrl}/comment`, {data: username, commentId: commentId}).then(data => { - document.getElementById('comment-rating').innerHTML = `Rating: ${data.data.rating}`; - if(data.data.liked)e.target.innerHTML="unlike"; - else{e.target.innerHTML="like"} + // document.getElementsByClassName('username').forEach(element => { + // element.innerHTML = `Rating: ${data.data.rating}`; + // }); + ratingElement.innerHTML = `Rating: ${data.data.rating}`; + if(data.data.liked)e.target.innerHTML="Unlike"; + else{e.target.innerHTML="Like"} }) } }); diff --git a/routes/protected.js b/routes/protected.js index 2a106ae..737d391 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -103,29 +103,5 @@ router.patch('/comment', async (req, res, next)=>{ }) }).catch(err => console.log(err)); }); -module.exports = router; -// router.post('/comment', (req, res, next) => { -// let articleId = req.headers.referer.match(/[^\/]\w*$/)[0]; -// let userId = req.session.passport.user -// Comment.create({ -// content: req.body.comment, -// author: userId, -// article: mongoose.Types.ObjectId(articleId), -// ratings: [], -// rating: 0 -// }).then(data => { -// //this needs to be done with post middleware -// User.findByIdAndUpdate(userId, -// {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) -// .then(data => console.log(data)); -// Article.findByIdAndUpdate( -// mongoose.Types.ObjectId(articleId), -// {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) -// .then(data => console.log(data.length)); -// User.find({_id: userId}).then(user=>{ -// res.status(200).send({data, user}); -// }) -// }).catch( -// err =>console.log(err)); -// }); +module.exports = router; From 4305cb1502906fe654779dfabb271e39f9e3f70f Mon Sep 17 00:00:00 2001 From: cule219 Date: Sat, 13 Jul 2019 00:48:19 +0200 Subject: [PATCH 34/40] fixed bunch of issues - hopefully correctly --- app.js | 4 ---- passport/facebookStrategy.js | 40 ++++++++++++++++++------------------ passport/githubStrategy.js | 2 +- public/javascripts/script.js | 1 - routes/homepages.js | 10 ++++++++- routes/protected.js | 34 +++++++----------------------- views/homepages/article.hbs | 2 +- views/profile/source.hbs | 2 +- 8 files changed, 39 insertions(+), 56 deletions(-) diff --git a/app.js b/app.js index 8be7e31..709e51b 100644 --- a/app.js +++ b/app.js @@ -12,7 +12,6 @@ const path = require('path'); const session = require("express-session"); const MongoStore = require('connect-mongo')(session); const flash = require("connect-flash"); -const axios = require('axios'); mongoose .connect(process.env.MONGO_URI || 'mongodb://localhost/project2', {useNewUrlParser: true}) @@ -69,11 +68,9 @@ hbs.registerHelper('ifUndefined', (value, options) => { } }); - // default value for title local app.locals.title = 'Express - Generated with IronGenerator'; - // Enable authentication using session + passport app.use(session({ secret: process.env.SESSION_SECRET, @@ -83,7 +80,6 @@ app.use(session({ })) app.use(flash()); require('./passport')(app); - app.use('/', require('./routes/index')); app.use('/', require('./routes/homepages')); diff --git a/passport/facebookStrategy.js b/passport/facebookStrategy.js index e0a3395..2e3f221 100644 --- a/passport/facebookStrategy.js +++ b/passport/facebookStrategy.js @@ -2,23 +2,23 @@ const FacebookStrategy = require("passport-facebook").Strategy; const passport = require('passport'); const User = require('../models/User'); -// passport.use(new FacebookStrategy({ -// clientID: process.env.FACEBOOK_USER_ID, -// clientSecret: process.env.FACEBOOK_KEY, -// callbackURL: "http://opinion-news.herokuapp.com/auth/facebook/callback" -// }, -// function(accessToken, refreshToken, profile, cb) { -// User.findOne({ facebookId: profile.id }).then(user => { -// if (user) return cb(null, user); -// console.log('FB user: ' + user) -// return User.create({ -// facebookId: profile.id, -// fullName: profile.displayName -// }).then(newUser => { -// return cb(null, newUser); -// }); -// }).catch(err => { -// cb(err); -// }); -// } -// )); +passport.use(new FacebookStrategy({ + clientID: process.env.FACEBOOK_USER_ID, + clientSecret: process.env.FACEBOOK_KEY, + callbackURL: "http://opinion-news.herokuapp.com/auth/facebook/callback" + }, + function(accessToken, refreshToken, profile, cb) { + User.findOne({ facebookId: profile.id }).then(user => { + if (user) return cb(null, user); + console.log('FB user: ' + user) + return User.create({ + facebookId: profile.id, + fullName: profile.displayName + }).then(newUser => { + return cb(null, newUser); + }); + }).catch(err => { + cb(err); + }); + } +)); diff --git a/passport/githubStrategy.js b/passport/githubStrategy.js index e08bcb4..e469227 100644 --- a/passport/githubStrategy.js +++ b/passport/githubStrategy.js @@ -5,7 +5,7 @@ const User = require('../models/User'); passport.use(new GitHubStrategy({ clientID: process.env.GITHUB_CLIENT_ID, clientSecret: process.env.GITHUB_CLIENT_SECRET, - callbackURL: "http://localhost:3000/auth/github/callback" + callbackURL: "http://opinion-news.herokuapp.com/auth/github/callback" }, function(accessToken, refreshToken, profile, cb) { User.findOne({ githubId: profile.id }) diff --git a/public/javascripts/script.js b/public/javascripts/script.js index 6eed201..683ad13 100644 --- a/public/javascripts/script.js +++ b/public/javascripts/script.js @@ -76,7 +76,6 @@ if(commentBox != undefined){ if(e.target.className == 'like-button'){ let username = e.target.parentNode.getElementsByTagName('h3')[0].innerHTML; let ratingElement = e.target.parentNode.getElementsByTagName('p')[1]; - console.log(ratingElement) let commentId = e.target.value; axios.patch(`${baseUrl}/comment`, {data: username, commentId: commentId}).then(data => { // document.getElementsByClassName('username').forEach(element => { diff --git a/routes/homepages.js b/routes/homepages.js index f12c7ad..55bff1c 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -11,12 +11,20 @@ router.get('/homepages/sources', (req, res) => { router.get('/article/:articleId', (req, res, next) => { let liked = false; + Article.findOne({'_id': req.params.articleId }).populate({ path: 'comments', populate: {path: 'author'}}).then(article =>{ - if(req.user != undefined)if(article.ratings.indexOf(req.user._id) !== -1)liked=true; + if(req.user != undefined){ + if(article.ratings.indexOf(req.user._id) !== -1)liked=true; + } article.title = article.title.substring(0, article.title.lastIndexOf('-')); article.publishDate = article.publishedAt.toDateString(); Source.findOne({ 'id': article.source.id }).then(source => { + if(req.user._id !== -1) { + article.comments.forEach(element => { + element.liked = element.ratings.includes(req.user._id); + }); + } res.render('homepages/article', {article, source, user: req.user, liked}); }) }).catch(err=>console.log(err)); diff --git a/routes/protected.js b/routes/protected.js index 46a8547..3ec555e 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -87,17 +87,21 @@ router.patch('/comment', async (req, res, next)=>{ const userId = req.session.passport.user; Comment.findOne({'_id': req.body.commentId}, (err, doc)=> { let docObject = doc._doc; + let incdec; if(docObject.ratings === undefined) {docObject.ratings = []; docObject.rating = 0} if(docObject.ratings.indexOf(userId) === -1){ docObject.ratings.push(userId); - docObject.rating++; + incdec=1; }else{ docObject.ratings.pull(mongoose.Types.ObjectId(userId)); - docObject.rating--; + incdec=-1; } + User.findByIdAndUpdate(docObject.author, { + $inc: {reputation: incdec} + },{ new: true }).then(data => console.log(data)) Comment.findByIdAndUpdate(docObject._id, { ratings: docObject.ratings, - rating: docObject.rating + rating: docObject.rating + incdec }, { new: true }).then(data => { console.log(docObject.ratings.includes(req.session.passport.user)); res.send({ @@ -109,27 +113,3 @@ router.patch('/comment', async (req, res, next)=>{ }); module.exports = router; -// router.post('/comment', (req, res, next) => { -// let articleId = req.headers.referer.match(/[^\/]\w*$/)[0]; -// let userId = req.session.passport.user -// Comment.create({ -// content: req.body.comment, -// author: userId, -// article: mongoose.Types.ObjectId(articleId), -// ratings: [], -// rating: 0 -// }).then(data => { -// //this needs to be done with post middleware -// User.findByIdAndUpdate(userId, -// {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) -// .then(data => console.log(data)); -// Article.findByIdAndUpdate( -// mongoose.Types.ObjectId(articleId), -// {$push: {'comments': mongoose.Types.ObjectId(data._id)}}) -// .then(data => console.log(data.length)); -// User.find({_id: userId}).then(user=>{ -// res.status(200).send({data, user}); -// }) -// }).catch( -// err =>console.log(err)); -// }); diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index 534560f..08dd185 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -67,7 +67,7 @@

{{this.content}}

Rating: {{this.rating}}

{{!-- {{#if user}} --}} - + {{!-- {{/if}} --}} diff --git a/views/profile/source.hbs b/views/profile/source.hbs index 23c11ea..5c67337 100644 --- a/views/profile/source.hbs +++ b/views/profile/source.hbs @@ -6,7 +6,7 @@

{{data.name}}

-

Rating: 4.8

+

Rating: {{data.reputation}}

{{data.url}} {{#if user}} Edit profile From 3ac5d3cc4dac18c5f561dbff57515a1c74ce271d Mon Sep 17 00:00:00 2001 From: cule219 Date: Sat, 13 Jul 2019 00:50:16 +0200 Subject: [PATCH 35/40] commit before merge --- passport/facebookStrategy.js | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/passport/facebookStrategy.js b/passport/facebookStrategy.js index 2e3f221..e0a3395 100644 --- a/passport/facebookStrategy.js +++ b/passport/facebookStrategy.js @@ -2,23 +2,23 @@ const FacebookStrategy = require("passport-facebook").Strategy; const passport = require('passport'); const User = require('../models/User'); -passport.use(new FacebookStrategy({ - clientID: process.env.FACEBOOK_USER_ID, - clientSecret: process.env.FACEBOOK_KEY, - callbackURL: "http://opinion-news.herokuapp.com/auth/facebook/callback" - }, - function(accessToken, refreshToken, profile, cb) { - User.findOne({ facebookId: profile.id }).then(user => { - if (user) return cb(null, user); - console.log('FB user: ' + user) - return User.create({ - facebookId: profile.id, - fullName: profile.displayName - }).then(newUser => { - return cb(null, newUser); - }); - }).catch(err => { - cb(err); - }); - } -)); +// passport.use(new FacebookStrategy({ +// clientID: process.env.FACEBOOK_USER_ID, +// clientSecret: process.env.FACEBOOK_KEY, +// callbackURL: "http://opinion-news.herokuapp.com/auth/facebook/callback" +// }, +// function(accessToken, refreshToken, profile, cb) { +// User.findOne({ facebookId: profile.id }).then(user => { +// if (user) return cb(null, user); +// console.log('FB user: ' + user) +// return User.create({ +// facebookId: profile.id, +// fullName: profile.displayName +// }).then(newUser => { +// return cb(null, newUser); +// }); +// }).catch(err => { +// cb(err); +// }); +// } +// )); From 0bd1854cfb8e941ebeed3088b79c2808631bb89c Mon Sep 17 00:00:00 2001 From: cule219 Date: Sat, 13 Jul 2019 00:56:30 +0200 Subject: [PATCH 36/40] bug fix --- routes/protected.js | 21 --------------------- views/homepages/article.hbs | 4 ---- views/profile/editUser.hbs | 4 ---- views/profile/user.hbs | 4 ---- 4 files changed, 33 deletions(-) diff --git a/routes/protected.js b/routes/protected.js index 82fc08f..2a419c3 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -87,23 +87,6 @@ router.patch('/comment', async (req, res, next)=>{ const userId = req.session.passport.user; Comment.findOne({'_id': req.body.commentId}, (err, doc)=> { let docObject = doc._doc; -<<<<<<< HEAD - if(docObject.ratings === undefined) {docObject.ratings = []; docObject.rating = 0} - if(docObject.ratings.indexOf(userId) === -1){ - docObject.ratings.push(userId); - docObject.rating++; - }else{ - docObject.ratings.pull(mongoose.Types.ObjectId(userId)); - docObject.rating--; - } - doc.save(doc).then(data => { - res.send({ - rating: data.rating, liked: data.toObject().ratings.includes(req.session.passport.user) - }); - }) - }).catch(err => console.log(err)); -}); -======= let incdec; if(docObject.ratings === undefined) {docObject.ratings = []; docObject.rating = 0} if(docObject.ratings.indexOf(userId) === -1){ @@ -120,15 +103,11 @@ router.patch('/comment', async (req, res, next)=>{ ratings: docObject.ratings, rating: docObject.rating + incdec }, { new: true }).then(data => { - console.log(docObject.ratings.includes(req.session.passport.user)); res.send({ rating: data.rating, liked: docObject.ratings.includes(req.session.passport.user) }); - // doc.save(doc). }) }).catch(err => console.log(err)); }); -module.exports = router; ->>>>>>> testB module.exports = router; diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index 6559de9..c1dac11 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -68,11 +68,7 @@

{{this.content}}

Rating: {{this.rating}}

{{!-- {{#if user}} --}} -<<<<<<< HEAD - -======= ->>>>>>> testB {{!-- {{/if}} --}}
diff --git a/views/profile/editUser.hbs b/views/profile/editUser.hbs index 576b002..8d55636 100644 --- a/views/profile/editUser.hbs +++ b/views/profile/editUser.hbs @@ -40,12 +40,8 @@ {{#each userComments}} {{this}} {{/each}} -<<<<<<< HEAD

No recent comments

-======= - ->>>>>>> testB diff --git a/views/profile/user.hbs b/views/profile/user.hbs index a48721d..724d76f 100644 --- a/views/profile/user.hbs +++ b/views/profile/user.hbs @@ -32,13 +32,9 @@ {{#each userComments}} {{this}} {{/each}} -<<<<<<< HEAD

No recent comments

-======= - ->>>>>>> testB From 72a23a09c2b204f717c2ffba87b145d3b8b9e922 Mon Sep 17 00:00:00 2001 From: cule219 Date: Sat, 13 Jul 2019 09:54:30 +0200 Subject: [PATCH 37/40] no user bug fix --- routes/homepages.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/homepages.js b/routes/homepages.js index 55bff1c..f91b02c 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -20,7 +20,7 @@ router.get('/article/:articleId', (req, res, next) => { article.title = article.title.substring(0, article.title.lastIndexOf('-')); article.publishDate = article.publishedAt.toDateString(); Source.findOne({ 'id': article.source.id }).then(source => { - if(req.user._id !== -1) { + if(req.user != undefined) { article.comments.forEach(element => { element.liked = element.ratings.includes(req.user._id); }); From 4c6cd6e1941e7ea6da618dc8f5f4297c579abec0 Mon Sep 17 00:00:00 2001 From: cule219 Date: Sat, 13 Jul 2019 10:18:24 +0200 Subject: [PATCH 38/40] no-user like shown bug fix --- routes/homepages.js | 1 + views/homepages/article.hbs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/routes/homepages.js b/routes/homepages.js index f91b02c..787408d 100644 --- a/routes/homepages.js +++ b/routes/homepages.js @@ -23,6 +23,7 @@ router.get('/article/:articleId', (req, res, next) => { if(req.user != undefined) { article.comments.forEach(element => { element.liked = element.ratings.includes(req.user._id); + element.user = req.user._id; }); } res.render('homepages/article', {article, source, user: req.user, liked}); diff --git a/views/homepages/article.hbs b/views/homepages/article.hbs index c1dac11..2c66b4e 100644 --- a/views/homepages/article.hbs +++ b/views/homepages/article.hbs @@ -67,9 +67,9 @@

{{this.author.username}}

{{this.content}}

Rating: {{this.rating}}

- {{!-- {{#if user}} --}} + {{#if this.user}} - {{!-- {{/if}} --}} + {{/if}} {{/each}} From 5b942b369b8d2bc5789d5f491266bf982c4d3e07 Mon Sep 17 00:00:00 2001 From: cule219 Date: Sat, 13 Jul 2019 21:39:18 +0200 Subject: [PATCH 39/40] check added for brick avoidance --- routes/protected.js | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/protected.js b/routes/protected.js index 2a419c3..abea447 100644 --- a/routes/protected.js +++ b/routes/protected.js @@ -31,6 +31,7 @@ router.patch('/article', (req, res, next)=>{ let userId = req.session.passport.user; Article.findOne({'_id': articleId}, (err, doc)=>{ if(err)console.log(err); + if(doc.ratings === null)doc.ratings=[]; if(doc.ratings.indexOf(userId) === -1) { doc.ratings.push(userId); From bbf4dc75934b44850d3a3a56f5e2a7fc4d9bc5ca Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Wed, 5 Feb 2020 01:05:35 +0000 Subject: [PATCH 40/40] fix: upgrade axios from 0.19.0 to 0.19.1 Snyk has created this PR to upgrade axios from 0.19.0 to 0.19.1. See this package in NPM: https://www.npmjs.com/package/axios See this project in Snyk: https://app.snyk.io/org/cule219/project/fb7baf1a-374e-4e6b-8201-86c21128d7d5?utm_source=github&utm_medium=upgrade-pr --- package-lock.json | 16 ++++------------ package.json | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 713c18a..37a2af9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -224,19 +224,11 @@ "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" }, "axios": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", - "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.1.tgz", + "integrity": "sha512-Yl+7nfreYKaLRvAvjNPkvfjnQHJM1yLBY3zhqAwcJSwR/6ETkanUgylgtIvkvz0xJ+p/vZuNw8X7Hnb7Whsbpw==", "requires": { - "follow-redirects": "1.5.10", - "is-buffer": "^2.0.2" - }, - "dependencies": { - "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" - } + "follow-redirects": "1.5.10" } }, "balanced-match": { diff --git a/package.json b/package.json index 00833c4..bbee31e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "dev-windows": "nodemon ./bin/www" }, "dependencies": { - "axios": "^0.19.0", + "axios": "^0.19.1", "bcrypt": "^3.0.0", "body-parser": "^1.18.3", "connect-ensure-login": "^0.1.1",