MCPcopy Create free account
hub / github.com/codecombat/codecombat / checkEmail

Method checkEmail

app/views/teachers/RequestQuoteView.js:522–556  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

520 }
521
522 checkEmail () {
523 const email = this.$('[name="email"]').val()
524
525 if (!_.isEmpty(email) && (email === this.state.get('checkEmailValue'))) {
526 return this.state.get('checkEmailPromise')
527 }
528
529 if (!(email && forms.validateEmail(email))) {
530 this.state.set({
531 checkEmailState: 'standby',
532 checkEmailValue: email,
533 checkEmailPromise: null
534 })
535 return Promise.resolve()
536 }
537
538 this.state.set({
539 checkEmailState: 'checking',
540 checkEmailValue: email,
541
542 checkEmailPromise: (User.checkEmailExists(email)
543 .then(({ exists }) => {
544 if (email !== this.$('[name="email"]').val()) { return }
545 if (exists) {
546 return this.state.set('checkEmailState', 'exists')
547 } else {
548 return this.state.set('checkEmailState', 'available')
549 }
550 }).catch(e => {
551 this.state.set('checkEmailState', 'standby')
552 throw e
553 }))
554 })
555 return this.state.get('checkEmailPromise')
556 }
557 }
558 RequestQuoteView.initClass()
559 return RequestQuoteView

Callers 2

onChangeEmailMethod · 0.95

Calls 3

checkEmailExistsMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected