diff --git a/common/models/user.json b/common/models/user.json index d0d8bed6e8..e1547203b1 100644 --- a/common/models/user.json +++ b/common/models/user.json @@ -133,6 +133,10 @@ "type": "boolean", "default": true }, + "lockdownMode": { + "type": "boolean", + "default": false + }, "currentChallenge": { "type": {} }, diff --git a/server/boot/user.js b/server/boot/user.js index f521404ced..2b08e4db62 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -68,6 +68,7 @@ module.exports = function(app) { router.post('/reset-password', postReset); router.get('/email-signup', getEmailSignup); router.get('/email-signin', getEmailSignin); + router.get('/toggle-lockdown-mode', toggleLockdownMode); router.post( '/account/delete', ifNoUser401, @@ -192,6 +193,35 @@ module.exports = function(app) { ); } + + + function toggleLockdownMode(req, res) { + if (req.user) { + if (req.user.lockdownMode === true) { + req.user.lockdownMode = false; + req.user.save(function (err) { + if (err) { + return next(err); + } + req.flash('success', {msg: 'Other people can now view all your challenge solutions. You can change this back at any time in the "Manage My Account" section at the bottom of this page.'}); + res.redirect(req.user.username); + }); + } else { + req.user.lockdownMode = true; + req.user.save(function (err) { + if (err) { + return next(err); + } + req.flash('success', {msg: 'All your challenge solutions are now hidden from other people. You can change this back at any time in the "Manage My Account" section at the bottom of this page.'}); + res.redirect(req.user.username); + }); + } + } else { + req.flash('error', {msg: 'You must be signed in to change your account settings.'}); + res.redirect('/'); + } + } + function postDeleteAccount(req, res, next) { User.destroyById(req.user.id, function(err) { if (err) { return next(err); } diff --git a/server/views/account/account.jade b/server/views/account/account.jade deleted file mode 100644 index 0259b504f7..0000000000 --- a/server/views/account/account.jade +++ /dev/null @@ -1,5 +0,0 @@ -extends ../layout -block content - script. - var challengeName = 'Account View' - diff --git a/server/views/account/show.jade b/server/views/account/show.jade index 2b80bba9f2..bee515fcff 100644 --- a/server/views/account/show.jade +++ b/server/views/account/show.jade @@ -5,7 +5,7 @@ block content var challengeName = 'Profile View'; if (user && user.username === username) .panel.panel-info - .panel-heading.text-center Manage your account + .panel-heading.text-center Update Your Portfolio .panel-body .row .col-xs-12 @@ -37,56 +37,18 @@ block content a.btn.btn-lg.btn-block.btn-google-plus.btn-link-social(href='/link/google') i.fa.fa-google-plus | Add my Google+ to my profile - .big-spacer - .col-xs-12 - a.btn.btn-lg.btn-block.btn-warning.btn-link-social(href='/logout') - span.ion-android-exit - | Sign me out of Free Code Camp - .col-xs-12 - a.btn.btn-lg.btn-block.btn-primary.btn-link-social(href='mailto:team@freecodecamp.com') - span.ion-email - | Email us at team@freecodecamp.com - .col-xs-12 - a.btn.btn-lg.btn-block.btn-danger.btn-link-social.confirm-deletion - span.ion-trash-b - | Delete my Free Code Camp account - script. - $('.confirm-deletion').on("click", function () { - $('#modal-dialog').modal('show'); - }); - #modal-dialog.modal.animated.wobble - .modal-dialog - .modal-content - .modal-header - a.close(href='#', data-dismiss='modal', aria-hidden='true') × - h3 You don't really want to delete your account, do you? - .modal-body - p This will really delete all your data, including all your progress, news stories and brownie points. - p We won't be able to recover any of it for you later, even if you change your mind. - p If there's something we could do better, send us an email instead and we'll do our best:   - a(href="mailto:team@freecodecamp.com") team@freecodecamp.com - | . - .modal-footer - a.btn.btn-success.btn-block(href='#', data-dismiss='modal', aria-hidden='true') - span.ion-happy - | Nevermind, I don't want to delete all my progress - .btn-spacer - form(action='/account/delete', method='POST') - input(type='hidden', name='_csrf', value=_csrf) - button.btn.btn-danger.btn-block(type='submit') - span.ion-trash-b - | I am 100% sure I want to delete all my progress + .panel.panel-info .panel-heading.text-center h1 #{username}'s portfolio .panel-body - .row.text-center - .col-xs-12.col-sm-10.col-sm-offset-1 - a.btn.btn-big.btn-primary.btn-block(href="/account") Manage my account - .button-spacer - .col-xs-12.col-sm-10.col-sm-offset-1 - a.btn.btn-big.btn-success.btn-block(href="/signout") Sign out of Free Code Camp - .spacer + .row.text-center + .col-xs-12.col-sm-10.col-sm-offset-1 + a.btn.btn-big.btn-primary.btn-block(href="/account") Manage my account + .button-spacer + .col-xs-12.col-sm-10.col-sm-offset-1 + a.btn.btn-big.btn-success.btn-block(href="/signout") Sign out of Free Code Camp + .spacer .row .col-xs-12 .col-xs-12.col-sm-12.col-md-5 @@ -166,21 +128,71 @@ block content td.col-xs-2= moment(challenge.completedDate, 'x').format("MMM DD, YYYY") td.col-xs-6 a(href=challenge.solution, target='_blank') View my solution - if (user && user.username === username) - br - if (bonfires.length > 0) - .col-sm-12 - table.table.table-striped - thead - tr - th.col-xs-4 Bonfire - th.col-xs-2 Completed - th.col-xs-6 Solution - for bonfire in bonfires - tr - td.col-xs-4 - a(href='/challenges/' + bonfire.name, target='_blank')= bonfire.name - td.col-xs-2= moment(bonfire.completedDate, 'x').format("MMM DD, YYYY") - td.col-xs-6 - pre.wrappable= bonfire.solution - br + if (bonfires.length > 0) + .col-sm-12 + table.table.table-striped + thead + tr + th.col-xs-4 Bonfire + th.col-xs-2 Completed + th.col-xs-6 Solution + for bonfire in bonfires + tr + td.col-xs-4 + a(href='/challenges/' + bonfire.name, target='_blank')= bonfire.name + td.col-xs-2= moment(bonfire.completedDate, 'x').format("MMM DD, YYYY") + td.col-xs-6 + pre.wrappable= bonfire.solution + + if (user && user.username === username) + .panel.panel-info + .panel-heading.text-center Manage Your Account + .panel-body + .col-xs-12 + a.btn.btn-lg.btn-block.btn-primary.btn-link-social(href='mailto:team@freecodecamp.com') + span.ion-email + | Email us at team@freecodecamp.com + if (!user.lockdownMode) + .col-xs-12 + a.btn.btn-lg.btn-block.btn-info.btn-link-social(href='/toggle-lockdown-mode') + span.ion-locked + | Hide all my solutions from other people + else + .col-xs-12 + a.btn.btn-lg.btn-block.btn-info.btn-link-social(href='/toggle-lockdown-mode') + span.ion-unlocked + | Let other people see all my solutions + .col-xs-12 + a.btn.btn-lg.btn-block.btn-warning.btn-link-social(href='/logout') + span.ion-android-exit + | Sign me out of Free Code Camp + .col-xs-12 + a.btn.btn-lg.btn-block.btn-danger.btn-link-social.confirm-deletion + span.ion-trash-b + | Delete my Free Code Camp account + script. + $('.confirm-deletion').on("click", function () { + $('#modal-dialog').modal('show'); + }); + #modal-dialog.modal.animated.wobble + .modal-dialog + .modal-content + .modal-header + a.close(href='#', data-dismiss='modal', aria-hidden='true') × + h3 You don't really want to delete your account, do you? + .modal-body + p This will really delete all your data, including all your progress, news stories and brownie points. + p We won't be able to recover any of it for you later, even if you change your mind. + p If there's something we could do better, send us an email instead and we'll do our best:   + a(href="mailto:team@freecodecamp.com") team@freecodecamp.com + | . + .modal-footer + a.btn.btn-success.btn-block(href='#', data-dismiss='modal', aria-hidden='true') + span.ion-happy + | Nevermind, I don't want to delete all my progress + .btn-spacer + form(action='/account/delete', method='POST') + input(type='hidden', name='_csrf', value=_csrf) + button.btn.btn-danger.btn-block(type='submit') + span.ion-trash-b + | I am 100% sure I want to delete all my progress