(e)
| 104 | } |
| 105 | |
| 106 | onSubmitForm (e) { |
| 107 | this.playSound('menu-button-click') |
| 108 | e.preventDefault() |
| 109 | forms.clearFormAlerts(this.$el) |
| 110 | this.$('#unknown-error-alert').addClass('hide') |
| 111 | const userObject = forms.formToObject(this.$el) |
| 112 | const res = tv4.validateMultiple(userObject, formSchema) |
| 113 | if (!res.valid) { return forms.applyErrorsToForm(this.$el, res.errors) } |
| 114 | let showingError = false |
| 115 | return new Promise(me.loginPasswordUser(userObject.emailOrUsername, userObject.password).then) |
| 116 | .catch(jqxhr => { |
| 117 | if (jqxhr.status === 401) { |
| 118 | const { |
| 119 | errorID, |
| 120 | } = jqxhr.responseJSON |
| 121 | if (errorID === 'not-found') { |
| 122 | forms.setErrorToProperty(this.$el, 'emailOrUsername', $.i18n.t('loading_error.' + (utils.isCodeCombat ? 'user_not_found' : 'not_found'))) // todo: update i18n |
| 123 | showingError = true |
| 124 | } |
| 125 | if (errorID === 'wrong-password') { |
| 126 | forms.setErrorToProperty(this.$el, 'password', $.i18n.t('account_settings.wrong_password')) |
| 127 | showingError = true |
| 128 | } |
| 129 | if (errorID === 'temp-password-expired') { |
| 130 | forms.setErrorToProperty(this.$el, 'password', $.i18n.t('account_settings.temp_password_expired')) |
| 131 | showingError = true |
| 132 | } |
| 133 | |
| 134 | if (utils.isOzaria && (errorID === 'individuals-not-supported')) { |
| 135 | forms.setErrorToProperty(this.$el, 'emailOrUsername', $.i18n.t('login.individual_users_not_supported')) |
| 136 | showingError = true |
| 137 | } |
| 138 | } else if (jqxhr.status === 429) { |
| 139 | showingError = true |
| 140 | forms.setErrorToProperty(this.$el, 'emailOrUsername', $.i18n.t('loading_error.too_many_login_failures')) |
| 141 | } |
| 142 | |
| 143 | if (!showingError) { |
| 144 | return this.$('#unknown-error-alert').removeClass('hide') |
| 145 | } |
| 146 | }) |
| 147 | .then(() => { |
| 148 | application.tracker.identifyAfterNextPageLoad() |
| 149 | return application.tracker.identify() |
| 150 | }) |
| 151 | .finally(() => { |
| 152 | if (!showingError) { |
| 153 | if (window.nextURL) { |
| 154 | return window.location.href = window.nextURL |
| 155 | } else { |
| 156 | return loginNavigate(this.subModalContinue) |
| 157 | } |
| 158 | } |
| 159 | }) |
| 160 | } |
| 161 | |
| 162 | // Google Plus |
| 163 |
nothing calls this directly
no test coverage detected