remove public accounts if user is not github cool or grandfathered
This commit is contained in:
@ -122,13 +122,28 @@ module.exports = function(app) {
|
||||
*/
|
||||
|
||||
function returnUser(req, res, next) {
|
||||
const username = req.params.username.toLowerCase();
|
||||
const { path } = req;
|
||||
User.findOne(
|
||||
{ where: { 'username': req.params.username.toLowerCase() } },
|
||||
{ where: { username } },
|
||||
function(err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
if (!user) {
|
||||
req.flash('errors', {
|
||||
msg: `404: We couldn't find path ${ path }`
|
||||
});
|
||||
return res.redirect('/');
|
||||
}
|
||||
if (!user.isGithubCool && !user.isMigrationGrandfathered) {
|
||||
req.flash('errors', {
|
||||
msg: `
|
||||
user ${ username } has not completed account signup
|
||||
`
|
||||
});
|
||||
return res.redirect('/');
|
||||
}
|
||||
user.progressTimestamps =
|
||||
user.progressTimestamps.sort(function(a, b) {
|
||||
return a - b;
|
||||
@ -197,14 +212,13 @@ module.exports = function(app) {
|
||||
|
||||
user.currentStreak = user.currentStreak || 1;
|
||||
user.longestStreak = user.longestStreak || 1;
|
||||
var challenges = user.completedChallenges.filter(function( obj ) {
|
||||
return obj.challengeType === 3 || obj.challengeType === 4;
|
||||
});
|
||||
|
||||
res.render('account/show', {
|
||||
title: 'Camper ' + user.username + '\'s portfolio',
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
isMigrationGrandfathered: user.isMigrationGrandfathered,
|
||||
isGithubCool: user.isGithubCool,
|
||||
location: user.location,
|
||||
githubProfile: user.githubProfile,
|
||||
linkedinProfile: user.linkedinProfile,
|
||||
@ -214,7 +228,6 @@ module.exports = function(app) {
|
||||
bio: user.bio,
|
||||
picture: user.picture,
|
||||
progressTimestamps: user.progressTimestamps,
|
||||
challenges: challenges,
|
||||
calender: data,
|
||||
moment: moment,
|
||||
longestStreak: user.longestStreak +
|
||||
@ -222,13 +235,6 @@ module.exports = function(app) {
|
||||
currentStreak: user.currentStreak +
|
||||
(user.currentStreak === 1 ? ' day' : ' days')
|
||||
});
|
||||
} else {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a page with that url. " +
|
||||
'Please double check the link.'
|
||||
});
|
||||
return res.redirect('/');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user