Some updates to the PR #2359

This commit is contained in:
laituan245 2015-02-25 01:54:30 +09:00
parent eb53381083
commit a588a3b2c8
4 changed files with 14 additions and 5 deletions

View file

@ -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) ->

View file

@ -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

View file

@ -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

View file

@ -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