Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-12-08 08:20:43 -08:00
commit 96cedec946

View file

@ -88,7 +88,9 @@ UserSchema.statics.updateServiceSettings = (doc, callback) ->
emailChanged = (not existingProps) or existingProps?.email isnt doc.get('email')
if emailChanged and customerID = doc.get('stripe')?.customerID
stripe.customers.update customerID, {email:doc.get('email')}, (err, customer) ->
unless stripe?.customers
console.error('Oh my god, Stripe is not imported correctly-how could we have done this (again)?')
stripe?.customers?.update customerID, {email:doc.get('email')}, (err, customer) ->
console.error('Error updating stripe customer...', err) if err
return callback?() unless emailChanged or doc.newsSubsChanged
@ -180,10 +182,10 @@ UserSchema.methods.register = (done) ->
@saveActiveUser 'register'
UserSchema.methods.isPremium = ->
return false unless stripe = @get('stripe')
return true if stripe.subscriptionID
return true if stripe.free is true
return true if _.isString(stripe.free) and new Date() < new Date(stripe.free)
return false unless stripeObject = @get('stripe')
return true if stripeObject.subscriptionID
return true if stripeObject.free is true
return true if _.isString(stripeObject.free) and new Date() < new Date(stripeObject.free)
return false
UserSchema.statics.saveActiveUser = (id, event, done=null) ->