mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Some updates to the PR #2359
This commit is contained in:
parent
eb53381083
commit
a588a3b2c8
4 changed files with 14 additions and 5 deletions
|
@ -50,7 +50,12 @@ module.exports.loginUser = (userObject, failure=genericFailure, nextURL=null) ->
|
|||
|
||||
module.exports.logoutUser = ->
|
||||
FB?.logout?()
|
||||
res = $.post('/auth/logout', {}, -> window.location.reload())
|
||||
callback = ->
|
||||
if (window.location.href.indexOf("/account/settings") > -1)
|
||||
window.location = '/'
|
||||
else
|
||||
window.location.reload()
|
||||
res = $.post('/auth/logout', {}, callback)
|
||||
res.fail(genericFailure)
|
||||
|
||||
onSetVolume = (e) ->
|
||||
|
|
|
@ -276,6 +276,7 @@ _.extend UserSchema.properties,
|
|||
|
||||
earned: c.RewardSchema 'earned by achievements'
|
||||
purchased: c.RewardSchema 'purchased with gems or money'
|
||||
deleted: {type: 'boolean'}
|
||||
spent: {type: 'number'}
|
||||
stripeCustomerID: { type: 'string' } # TODO: Migrate away from this property
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@ module.exports = class AccountSettingsView extends CocoView
|
|||
Backbone.Mediator.publish("auth:logging-out", {})
|
||||
window.tracker?.trackEvent 'Log Out', category:'Homepage', ['Google Analytics'] if @id is 'home-view'
|
||||
logoutUser($('#login-email').val())
|
||||
window.location = '../'
|
||||
, 500
|
||||
error: (jqXHR, status, error) ->
|
||||
console.error jqXHR
|
||||
|
|
|
@ -220,16 +220,20 @@ UserHandler = class UserHandler extends Handler
|
|||
|
||||
delete: (req, res, userID) ->
|
||||
# Instead of just deleting the User object, we should remove all the properties except for _id
|
||||
# And add a `deleted: true` property
|
||||
@getDocumentForIdOrSlug userID, (err, user) => # Check first
|
||||
return @sendDatabaseError res, err if err
|
||||
return @sendNotFoundError res unless user
|
||||
return @sendForbiddenError res unless @hasAccessToDocument(req, user)
|
||||
obj = user.toObject()
|
||||
for prop, val of obj
|
||||
if !(prop is '_id')
|
||||
user.set(prop, undefined)
|
||||
user.set('anonymous', true)
|
||||
user.set(prop, undefined) unless prop is '_id'
|
||||
user.set('deleted', true)
|
||||
|
||||
# Hack to get saving of Users to work. Probably should replace these props with strings
|
||||
# so that validation doesn't get hung up on Date objects in the documents.
|
||||
delete obj.dateCreated
|
||||
|
||||
user.save (err) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
@sendNoContent res
|
||||
|
|
Loading…
Reference in a new issue