mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Finish StudentLoginModal implementation
This commit is contained in:
parent
70a3a199a0
commit
f8a5baa4f6
2 changed files with 21 additions and 7 deletions
|
@ -22,8 +22,10 @@ block modal-body-content
|
|||
.input-border
|
||||
input#password.input-large.form-control(name="password", type="password", value=view.formValues.password)
|
||||
|
||||
#errors-alert.alert.alert-danger.hide
|
||||
|
||||
.text-center
|
||||
button#log-in-btn.btn.btn-default(data-i18n="login.log_in")
|
||||
input#log-in-btn.btn.btn-default(data-i18n="login.log_in", type="submit")
|
||||
p
|
||||
a#create-new-account-link(data-i18n="login.signup_switch")
|
||||
|
||||
|
|
|
@ -13,11 +13,23 @@ module.exports = class StudentSignInModal extends ModalView
|
|||
|
||||
events:
|
||||
'click #log-in-btn': 'onClickLogInButton'
|
||||
'submit form': 'onSubmitForm'
|
||||
|
||||
onSubmitForm: (e) ->
|
||||
e.preventDefault()
|
||||
@login()
|
||||
|
||||
onClickLogInButton: ->
|
||||
forms.clearFormAlerts(@$el)
|
||||
@login()
|
||||
|
||||
login: ->
|
||||
userObject = forms.formToObject @$el
|
||||
res = tv4.validateMultiple userObject, User.schema
|
||||
return forms.applyErrorsToForm(@$el, res.errors) unless res.valid
|
||||
@enableModalInProgress(@$el) # TODO: part of forms
|
||||
loginUser userObject, null, window.nextURL
|
||||
@enableModalInProgress(@$el)
|
||||
auth.loginUser userObject, (jqxhr) =>
|
||||
error = jqxhr.responseJSON[0]
|
||||
message = error.property + ' ' + error.message
|
||||
@disableModalInProgress(@$el)
|
||||
@$('#errors-alert').text(message).removeClass('hide')
|
||||
|
Loading…
Reference in a new issue