From 805ffaa50e4d945ba69d22bb336b47b5a75a0593 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sat, 7 Sep 2019 08:28:54 -0400 Subject: [PATCH] [+] Check the success flag in response --- src/components/login/login.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/login/login.ts b/src/components/login/login.ts index da99423..12a244f 100644 --- a/src/components/login/login.ts +++ b/src/components/login/login.ts @@ -31,8 +31,20 @@ export default class Login extends Vue // Get response body text res.text().then(text => { - // Call custom event with courses info - this.$emit('login:courses', JSON.parse(text)); + // Parse response + let response = JSON.parse(text); + + // Check success + if (response.success) + { + // Call custom event with courses info + this.$emit('login:token', response.token); + } + else + { + // Allow the user to retry + this.loading = false; + } }) }) .catch(err =>