diff --git a/frontend/src/api/repository.js b/frontend/src/api/repository.js index d4b0f9187..d353dc1bd 100644 --- a/frontend/src/api/repository.js +++ b/frontend/src/api/repository.js @@ -3,8 +3,11 @@ import Cookies from 'js-cookie' import router from '../router' import store from '../store' +import { translate } from 'vue-gettext' +import { bus } from '@/main' const _axios = axios.create() +const { gettext: $gettext } = translate _axios.interceptors.request.use( function (config) { @@ -32,7 +35,7 @@ _axios.interceptors.response.use( return Promise.reject(error) } if (error.response.status === 429) { - store.showNotification() + bus.$emit('notification', { msg: $gettext('You are throttled, please try later.'), type: 'error' }) return Promise.reject(error) } if (error.response.status !== 401 || router.currentRoute.path === '/login/') { diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue index be4d4759c..4141c18eb 100644 --- a/frontend/src/views/Login.vue +++ b/frontend/src/views/Login.vue @@ -89,12 +89,15 @@ export default { this.$router.push({ name: 'DomainList' }) }) }).catch(err => { - console.error(err) this.loading = false if (err.response.status === 401) { this.$refs.observer.setErrors({ password: this.$gettext('Invalid username and/or password') }) + } else if (err.response.status === 429) { + this.$refs.observer.setErrors({ + password: this.$gettext('Too many unsuccessful attempts, please try later.') + }) } }) } diff --git a/frontend/src/views/user/PasswordRecoveryChangeForm.vue b/frontend/src/views/user/PasswordRecoveryChangeForm.vue index 3055b9d13..2204bca68 100644 --- a/frontend/src/views/user/PasswordRecoveryChangeForm.vue +++ b/frontend/src/views/user/PasswordRecoveryChangeForm.vue @@ -81,7 +81,6 @@ export default { } else { const decodedId = atob(this.$route.params.id) if (!/^\d+$/.test(decodedId)) { - console.error('Received ID is invalid') this.$router.push({ name: 'PasswordRecoveryForm' }) } else { this.id = this.$route.params.id @@ -119,6 +118,10 @@ export default { err.response.data.errors.forEach(element => { message += this.$gettext(element) + '
' }) + } else if (err.response.status === 429) { + this.$refs.observer.setErrors({ + password: this.$gettext('Too many unsuccessful attempts, please try later.') + }) } this.password_validation_error = message }) diff --git a/frontend/src/views/user/PasswordRecoveryForm.vue b/frontend/src/views/user/PasswordRecoveryForm.vue index 516991229..d29c47490 100644 --- a/frontend/src/views/user/PasswordRecoveryForm.vue +++ b/frontend/src/views/user/PasswordRecoveryForm.vue @@ -110,6 +110,10 @@ export default { } } else if (err.response.status === 503 && err.response.data.type === 'email') { this.showDialog('Error', err.response.data.reason, true) + } else if (err.response.status === 429) { + this.$refs.observer.setErrors({ + password: this.$gettext('Too many unsuccessful attempts, please try later.') + }) } }) } diff --git a/frontend/src/views/user/PasswordRecoverySmsTotpForm.vue b/frontend/src/views/user/PasswordRecoverySmsTotpForm.vue index 2bcc55089..616f0b642 100644 --- a/frontend/src/views/user/PasswordRecoverySmsTotpForm.vue +++ b/frontend/src/views/user/PasswordRecoverySmsTotpForm.vue @@ -89,6 +89,10 @@ export default { if (err.response.status === 400) { this.loading = false this.showErrorDialog(this.$t('User seems wrong, return to login or restart reset the process?')) + } else if (err.response.status === 429) { + this.$refs.observer.setErrors({ + password: this.$gettext('Too many unsuccessful attempts, please try later.') + }) } }) },