Give more specific reason for failed login
This commit is contained in:
parent
c0e8111d64
commit
ccc460bb5e
3 changed files with 9 additions and 5 deletions
|
@ -10,8 +10,8 @@ const LoginForm = {
|
|||
submit () {
|
||||
this.$store.dispatch('loginUser', this.user).then(
|
||||
() => { this.$router.push('/main/friends')},
|
||||
() => {
|
||||
this.authError = true
|
||||
(error) => {
|
||||
this.authError = error
|
||||
this.user.username = ''
|
||||
this.user.password = ''
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<button :disabled="loggingIn" type='submit' class='btn btn-default base05 base01-background'>Submit</button>
|
||||
</div>
|
||||
<div v-if="authError" class='form-group'>
|
||||
<button disabled='true' class='btn btn-default base05 error'>Error logging in, try again</button>
|
||||
<button disabled='true' class='btn btn-default base05 error'>{{authError}}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -96,7 +96,11 @@ const users = {
|
|||
} else {
|
||||
// Authentication failed
|
||||
commit('endLogin')
|
||||
reject()
|
||||
if (response.status === 401) {
|
||||
reject('Wrong username or password')
|
||||
} else {
|
||||
reject('An error occured, please try again')
|
||||
}
|
||||
}
|
||||
commit('endLogin')
|
||||
resolve()
|
||||
|
@ -104,7 +108,7 @@ const users = {
|
|||
.catch((error) => {
|
||||
console.log(error)
|
||||
commit('endLogin')
|
||||
reject()
|
||||
reject('Failed to connect to server, try again')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue