Give more specific reason for failed login

This commit is contained in:
wakarimasen 2017-03-08 19:22:56 +01:00
parent c0e8111d64
commit ccc460bb5e
3 changed files with 9 additions and 5 deletions

View File

@ -10,8 +10,8 @@ const LoginForm = {
submit () { submit () {
this.$store.dispatch('loginUser', this.user).then( this.$store.dispatch('loginUser', this.user).then(
() => { this.$router.push('/main/friends')}, () => { this.$router.push('/main/friends')},
() => { (error) => {
this.authError = true this.authError = error
this.user.username = '' this.user.username = ''
this.user.password = '' this.user.password = ''
} }

View File

@ -18,7 +18,7 @@
<button :disabled="loggingIn" type='submit' class='btn btn-default base05 base01-background'>Submit</button> <button :disabled="loggingIn" type='submit' class='btn btn-default base05 base01-background'>Submit</button>
</div> </div>
<div v-if="authError" class='form-group'> <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> </div>
</form> </form>
</div> </div>

View File

@ -96,7 +96,11 @@ const users = {
} else { } else {
// Authentication failed // Authentication failed
commit('endLogin') commit('endLogin')
reject() if (response.status === 401) {
reject('Wrong username or password')
} else {
reject('An error occured, please try again')
}
} }
commit('endLogin') commit('endLogin')
resolve() resolve()
@ -104,7 +108,7 @@ const users = {
.catch((error) => { .catch((error) => {
console.log(error) console.log(error)
commit('endLogin') commit('endLogin')
reject() reject('Failed to connect to server, try again')
}) })
}) })
} }