diff --git a/src/components/Cards/Login.vue b/src/components/Cards/Login.vue
index 825fea30..76ea3489 100644
--- a/src/components/Cards/Login.vue
+++ b/src/components/Cards/Login.vue
@@ -5,6 +5,17 @@
{{title}}
+
+ {{ errorMessage }}
+
Forgot your password?
@@ -48,7 +56,7 @@ export default {
return {
email: '',
password: '',
- error: [],
+ errorMessage: '',
loggingIn: false
}
},
@@ -68,29 +76,24 @@ export default {
},
login (evt) {
evt.preventDefault()
-
this.loggingIn = true
const email = this.email
const password = this.password
- this.error = []
+ this.errorMessage = ''
+
this.$store
.dispatch('login', { email, password })
.then(() => this.$router.push('/dashboard'))
.catch(err => {
console.log(err.response)
- // If the api gave use details of the error, then use them
- if (err.response && err.response.data && err.response.data.errors) {
- if (err.response.data.errors.email) {
- this.error.email = err.response.data.errors.email[0]
- }
- if (err.response.data.errors.password) {
- this.error.password = err.response.data.errors.password[0]
- }
- } else {
- this.error.email = 'Could not log in.'
- this.error.password = 'Could not log in.'
- }
+ this.errorMessage = 'Incorrect username or password. Please try again.'
+
+ this.password = ''
+
+ this.$nextTick(() => {
+ this.$refs.passwordField.$el.querySelector('input').focus()
+ })
this.loggingIn = false
})
@@ -102,7 +105,6 @@ export default {