add lockdown mode toggling
This commit is contained in:
@ -133,6 +133,10 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
|
"lockdownMode": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"currentChallenge": {
|
"currentChallenge": {
|
||||||
"type": {}
|
"type": {}
|
||||||
},
|
},
|
||||||
|
@ -68,6 +68,7 @@ module.exports = function(app) {
|
|||||||
router.post('/reset-password', postReset);
|
router.post('/reset-password', postReset);
|
||||||
router.get('/email-signup', getEmailSignup);
|
router.get('/email-signup', getEmailSignup);
|
||||||
router.get('/email-signin', getEmailSignin);
|
router.get('/email-signin', getEmailSignin);
|
||||||
|
router.get('/toggle-lockdown-mode', toggleLockdownMode);
|
||||||
router.post(
|
router.post(
|
||||||
'/account/delete',
|
'/account/delete',
|
||||||
ifNoUser401,
|
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) {
|
function postDeleteAccount(req, res, next) {
|
||||||
User.destroyById(req.user.id, function(err) {
|
User.destroyById(req.user.id, function(err) {
|
||||||
if (err) { return next(err); }
|
if (err) { return next(err); }
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
extends ../layout
|
|
||||||
block content
|
|
||||||
script.
|
|
||||||
var challengeName = 'Account View'
|
|
||||||
|
|
@ -5,7 +5,7 @@ block content
|
|||||||
var challengeName = 'Profile View';
|
var challengeName = 'Profile View';
|
||||||
if (user && user.username === username)
|
if (user && user.username === username)
|
||||||
.panel.panel-info
|
.panel.panel-info
|
||||||
.panel-heading.text-center Manage your account
|
.panel-heading.text-center Update Your Portfolio
|
||||||
.panel-body
|
.panel-body
|
||||||
.row
|
.row
|
||||||
.col-xs-12
|
.col-xs-12
|
||||||
@ -37,45 +37,7 @@ block content
|
|||||||
a.btn.btn-lg.btn-block.btn-google-plus.btn-link-social(href='/link/google')
|
a.btn.btn-lg.btn-block.btn-google-plus.btn-link-social(href='/link/google')
|
||||||
i.fa.fa-google-plus
|
i.fa.fa-google-plus
|
||||||
| Add my Google+ to my profile
|
| 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.panel-info
|
||||||
.panel-heading.text-center
|
.panel-heading.text-center
|
||||||
h1 #{username}'s portfolio
|
h1 #{username}'s portfolio
|
||||||
@ -166,8 +128,6 @@ block content
|
|||||||
td.col-xs-2= moment(challenge.completedDate, 'x').format("MMM DD, YYYY")
|
td.col-xs-2= moment(challenge.completedDate, 'x').format("MMM DD, YYYY")
|
||||||
td.col-xs-6
|
td.col-xs-6
|
||||||
a(href=challenge.solution, target='_blank') View my solution
|
a(href=challenge.solution, target='_blank') View my solution
|
||||||
if (user && user.username === username)
|
|
||||||
br
|
|
||||||
if (bonfires.length > 0)
|
if (bonfires.length > 0)
|
||||||
.col-sm-12
|
.col-sm-12
|
||||||
table.table.table-striped
|
table.table.table-striped
|
||||||
@ -183,4 +143,56 @@ block content
|
|||||||
td.col-xs-2= moment(bonfire.completedDate, 'x').format("MMM DD, YYYY")
|
td.col-xs-2= moment(bonfire.completedDate, 'x').format("MMM DD, YYYY")
|
||||||
td.col-xs-6
|
td.col-xs-6
|
||||||
pre.wrappable= bonfire.solution
|
pre.wrappable= bonfire.solution
|
||||||
br
|
|
||||||
|
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
|
||||||
|
Reference in New Issue
Block a user