mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Don't delete the User object, just remove all the properties except for _id
This commit is contained in:
parent
d325623699
commit
eb53381083
2 changed files with 9 additions and 2 deletions
|
@ -100,7 +100,7 @@ module.exports = class AccountSettingsView extends CocoView
|
||||||
Backbone.Mediator.publish("auth:logging-out", {})
|
Backbone.Mediator.publish("auth:logging-out", {})
|
||||||
window.tracker?.trackEvent 'Log Out', category:'Homepage', ['Google Analytics'] if @id is 'home-view'
|
window.tracker?.trackEvent 'Log Out', category:'Homepage', ['Google Analytics'] if @id is 'home-view'
|
||||||
logoutUser($('#login-email').val())
|
logoutUser($('#login-email').val())
|
||||||
window.location = '../';
|
window.location = '../'
|
||||||
, 500
|
, 500
|
||||||
error: (jqXHR, status, error) ->
|
error: (jqXHR, status, error) ->
|
||||||
console.error jqXHR
|
console.error jqXHR
|
||||||
|
|
|
@ -219,11 +219,18 @@ UserHandler = class UserHandler extends Handler
|
||||||
return true
|
return true
|
||||||
|
|
||||||
delete: (req, res, userID) ->
|
delete: (req, res, userID) ->
|
||||||
|
# Instead of just deleting the User object, we should remove all the properties except for _id
|
||||||
@getDocumentForIdOrSlug userID, (err, user) => # Check first
|
@getDocumentForIdOrSlug userID, (err, user) => # Check first
|
||||||
return @sendDatabaseError res, err if err
|
return @sendDatabaseError res, err if err
|
||||||
return @sendNotFoundError res unless user
|
return @sendNotFoundError res unless user
|
||||||
return @sendForbiddenError res unless @hasAccessToDocument(req, user)
|
return @sendForbiddenError res unless @hasAccessToDocument(req, user)
|
||||||
user.remove (err, user) =>
|
obj = user.toObject()
|
||||||
|
for prop, val of obj
|
||||||
|
if !(prop is '_id')
|
||||||
|
user.set(prop, undefined)
|
||||||
|
user.set('anonymous', true)
|
||||||
|
delete obj.dateCreated
|
||||||
|
user.save (err) =>
|
||||||
return @sendDatabaseError(res, err) if err
|
return @sendDatabaseError(res, err) if err
|
||||||
@sendNoContent res
|
@sendNoContent res
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue