MCPcopy Index your code
hub / github.com/codecombat/codecombat / hasSubscription

Method hasSubscription

app/models/User.js:526–544  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

524 }
525
526 hasSubscription () {
527 if (this.isStudent() || this.isTeacher()) { return false }
528 const payPal = this.get('payPal')
529 const stripe = this.get('stripe')
530 const products = this.get('products')
531 if (payPal) {
532 if (payPal.billingAgreementID) { return true }
533 }
534 if (stripe) {
535 if (stripe.free === true) { return true }
536 if (_.isString(stripe.free) && (new Date() < new Date(stripe.free))) { return true }
537 }
538 if (products) {
539 const homeProducts = this.activeProducts('basic_subscription')
540 const maxFree = _.max(homeProducts, p => new Date(p.endDate)).endDate
541 if (new Date() < new Date(maxFree)) { return true }
542 }
543 return false
544 }
545
546 isPaidOnlineClassUser () {
547 const products = this.get('products')

Callers 9

isPremiumMethod · 0.95
enableCppMethod · 0.95
enableJavaMethod · 0.95
''Method · 0.80
saveAndHideMethod · 0.80

Calls 4

isStudentMethod · 0.95
isTeacherMethod · 0.95
getMethod · 0.95
activeProductsMethod · 0.95

Tested by

no test coverage detected