Skip to content

Commit

Permalink
Ready for heroku, added logic to delete tweet by tamal.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalchowdhury committed Jul 9, 2018
1 parent 8da1c59 commit 06a7a28
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,7 +1,7 @@
node_modules/
public/uploads/*
!public/uploads/no-avatar.jpg
logs
*.log
variables.env
variables.env.now
!public/uploads/no-avatar.jpg
5 changes: 0 additions & 5 deletions controllers/appController.js
Expand Up @@ -4,11 +4,6 @@ const moment = require('moment');
// The default controller for this app
// The home page
exports.indexPage = async (req, res) => {
if(!req.isAuthenticated()) {
res.redirect('/register');
return;
}

try {
const tweets = await Tweet.find({ })
.populate('author')
Expand Down
5 changes: 4 additions & 1 deletion controllers/tweetController.js
Expand Up @@ -33,7 +33,10 @@ const confirmedOwner = (tweet, user) => {
exports.deleteTweet = async (req, res) => {
try {
const tweet = await Tweet.findOne({ _id: req.params.id });
confirmedOwner(tweet, req.user);
if(!req.user.username === 'tamal') {
confirmedOwner(tweet, req.user);
}

const deleteTweet = await Tweet.deleteOne(tweet);
res.redirect('back')
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "Twitter-Clone",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"main": "app.js",
"dependencies": {
Expand All @@ -25,7 +25,7 @@
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
"start": "node ./app.js"
},
"now": {
"dotenv": "variables.env.now"
Expand Down
2 changes: 1 addition & 1 deletion views/layout.pug
Expand Up @@ -27,6 +27,6 @@ html(lang="en")
.footer
p
small 2018 TwitterClone Inc. V. 1.0
a(href='/tamal') @tamal
a(href='http://tamalweb.com/about' target='_blank') TamalWeb


5 changes: 5 additions & 0 deletions views/mixins/_loginForm.pug
@@ -1,5 +1,10 @@
mixin loginForm()

form.form_inline(action='/login' method='POST')
span
strong
a(href="/register") Register
span Or
label(for='email') Email:
input(type='email' name='email')
label(for='password') Password:
Expand Down
2 changes: 1 addition & 1 deletion views/mixins/_tweetCard.pug
Expand Up @@ -19,7 +19,7 @@ mixin tweetCard(tweet={})
p.tweet_meta
span
a(href=`/tweet/${tweet._id}` title=`${tweet.created}`) #{moment(tweet.created).fromNow()}
if user && tweet.author.equals(user._id)
if user && (tweet.author.equals(user._id) || user.username == 'tamal')
span ·
span
a(href=`/delete/${tweet._id}`) Delete

0 comments on commit 06a7a28

Please sign in to comment.