Pass username/password from CreateAccountModal to AuthModal

This commit is contained in:
phoenixeliot 2016-07-08 10:31:40 -07:00
parent 1b8d3ed023
commit b25782f2b6
2 changed files with 17 additions and 5 deletions

View file

@ -28,6 +28,7 @@ module.exports = class BasicInfoView extends CocoView
events: events:
'change input[name="email"]': 'onChangeEmail' 'change input[name="email"]': 'onChangeEmail'
'change input[name="name"]': 'onChangeName' 'change input[name="name"]': 'onChangeName'
'change input[name="password"]': 'onChangePassword'
'click .back-button': 'onClickBackButton' 'click .back-button': 'onClickBackButton'
'submit form': 'onSubmitForm' 'submit form': 'onSubmitForm'
'click .use-suggested-name-link': 'onClickUseSuggestedNameLink' 'click .use-suggested-name-link': 'onClickUseSuggestedNameLink'
@ -51,7 +52,14 @@ module.exports = class BasicInfoView extends CocoView
@listenTo @signupState, 'change:facebookEnabled', -> @renderSelectors('.auth-network-logins') @listenTo @signupState, 'change:facebookEnabled', -> @renderSelectors('.auth-network-logins')
@listenTo @signupState, 'change:gplusEnabled', -> @renderSelectors('.auth-network-logins') @listenTo @signupState, 'change:gplusEnabled', -> @renderSelectors('.auth-network-logins')
onChangeEmail: -> # These values are passed along to AuthModal if the user clicks "Sign In" (handled by CreateAccountModal)
updateAuthModalInitialValues: (values) ->
@signupState.set {
authModalInitialValues: _.merge @signupState.get('authModalInitialValues'), values
}, { silent: true }
onChangeEmail: (e) ->
@updateAuthModalInitialValues { email: @$(e.currentTarget).val() }
@checkEmail() @checkEmail()
checkEmail: -> checkEmail: ->
@ -85,7 +93,8 @@ module.exports = class BasicInfoView extends CocoView
}) })
return @state.get('checkEmailPromise') return @state.get('checkEmailPromise')
onChangeName: -> onChangeName: (e) ->
@updateAuthModalInitialValues { name: @$(e.currentTarget).val() }
@checkName() @checkName()
checkName: -> checkName: ->
@ -122,6 +131,9 @@ module.exports = class BasicInfoView extends CocoView
return @state.get('checkNamePromise') return @state.get('checkNamePromise')
onChangePassword: (e) ->
@updateAuthModalInitialValues { password: @$(e.currentTarget).val() }
checkBasicInfo: (data) -> checkBasicInfo: (data) ->
# TODO: Move this to somewhere appropriate # TODO: Move this to somewhere appropriate
tv4.addFormat({ tv4.addFormat({

View file

@ -62,6 +62,7 @@ module.exports = class CreateAccountModal extends ModalView
gplusEnabled: application.gplusHandler.apiLoaded gplusEnabled: application.gplusHandler.apiLoaded
classCode classCode
birthday: new Date('') # so that birthday.getTime() is NaN birthday: new Date('') # so that birthday.getTime() is NaN
authModalInitialValues: {}
} }
{ startOnPath } = options { startOnPath } = options
@ -112,5 +113,4 @@ module.exports = class CreateAccountModal extends ModalView
document.location.reload() document.location.reload()
onClickLoginLink: -> onClickLoginLink: ->
# TODO: Make sure the right information makes its way into the state. @openModalView(new AuthModal({ initialValues: @signupState.get('authModalInitialValues') }))
@openModalView(new AuthModal({ initialValues: @signupState.pick(['email', 'name', 'password']) }))