add unsubscribe path
This commit is contained in:
10
app.js
10
app.js
@ -514,6 +514,16 @@ app.post(
|
|||||||
storyController.upvote
|
storyController.upvote
|
||||||
);
|
);
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
'/unsubscribe/:email',
|
||||||
|
resourcesController.unsubscribe
|
||||||
|
);
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
'/unsubscribed',
|
||||||
|
resourcesController.unsubscribed
|
||||||
|
);
|
||||||
|
|
||||||
app.all('/account', passportConf.isAuthenticated);
|
app.all('/account', passportConf.isAuthenticated);
|
||||||
|
|
||||||
app.get('/account/api', userController.getAccountAngular);
|
app.get('/account/api', userController.getAccountAngular);
|
||||||
|
@ -185,6 +185,35 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
unsubscribe: function unsubscribe(req, res) {
|
||||||
|
User.findOne({email: req.params.email}, function(err, user) {
|
||||||
|
console.log('---------');
|
||||||
|
console.log(req.params);
|
||||||
|
console.log('---------');
|
||||||
|
console.log(user);
|
||||||
|
if (user) {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
user.sendMonthlyEmail = false;
|
||||||
|
user.save(function () {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
res.redirect('/unsubscribed');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.redirect('/unsubscribed');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
unsubscribed: function unsubscribed(req, res) {
|
||||||
|
res.render('resources/unsubscribed', {
|
||||||
|
title: "You have been unsubscribed"
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
githubCalls: function(req, res) {
|
githubCalls: function(req, res) {
|
||||||
var githubHeaders = {headers: {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1521.3 Safari/537.36'}, port:80 };
|
var githubHeaders = {headers: {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1521.3 Safari/537.36'}, port:80 };
|
||||||
request('https://api.github.com/repos/freecodecamp/freecodecamp/pulls?client_id=' + secrets.github.clientID + '&client_secret=' + secrets.github.clientSecret, githubHeaders, function(err, status1, pulls) {
|
request('https://api.github.com/repos/freecodecamp/freecodecamp/pulls?client_id=' + secrets.github.clientID + '&client_secret=' + secrets.github.clientSecret, githubHeaders, function(err, status1, pulls) {
|
||||||
|
@ -141,6 +141,7 @@ var userSchema = new mongoose.Schema({
|
|||||||
},
|
},
|
||||||
needsMigration: { type: Boolean, default: true },
|
needsMigration: { type: Boolean, default: true },
|
||||||
finishedWaypoints: { type: Boolean, default: false },
|
finishedWaypoints: { type: Boolean, default: false },
|
||||||
|
sendMonthlyEmail: { type: Boolean, default: true },
|
||||||
challengesHash: {}
|
challengesHash: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
6
views/resources/unsubscribed.jade
Normal file
6
views/resources/unsubscribed.jade
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
extends ../layout
|
||||||
|
block content
|
||||||
|
.panel.panel-info
|
||||||
|
.panel-body.text-center
|
||||||
|
h1 You have successfully been unsubscribed.
|
||||||
|
h2 Whatever you do, keep coding! :)
|
Reference in New Issue
Block a user