From 1a6869c3ffbd1758a38185530b3484cbaaba6c0d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 Dec 2018 16:17:34 +0100 Subject: [PATCH] Fix login --- js/src/components/Account/Login.vue | 28 ++++++++++++++-------------- js/src/graphql/auth.ts | 4 ---- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/js/src/components/Account/Login.vue b/js/src/components/Account/Login.vue index 35897bc41..5babc7f8f 100644 --- a/js/src/components/Account/Login.vue +++ b/js/src/components/Account/Login.vue @@ -110,24 +110,25 @@ this.credentials.password = this.password; } - loginAction(e: Event) { + async loginAction(e: Event) { e.preventDefault(); - this.$apollo.mutate({ - mutation: LOGIN, - variables: { - email: this.credentials.email, - password: this.credentials.password, - }, - }).then((result) => { - console.log(result) + try { + const result = await this.$apollo.mutate({ + mutation: LOGIN, + variables: { + email: this.credentials.email, + password: this.credentials.password, + }, + }); + this.saveUserData(result.data); this.$router.push({ name: 'Home' }); - }).catch((e) => { - console.log(e); + } catch (err) { + console.error(err); this.error.show = true; - this.error.text = e.message; - }); + this.error.text = err.message; + } } validEmail() { @@ -136,7 +137,6 @@ saveUserData({ login: login }) { localStorage.setItem(AUTH_USER_ID, login.user.id); - localStorage.setItem(AUTH_USER_ACTOR, JSON.stringify(login.actor)); localStorage.setItem(AUTH_TOKEN, login.token); } } diff --git a/js/src/graphql/auth.ts b/js/src/graphql/auth.ts index 277343ec7..87d651faa 100644 --- a/js/src/graphql/auth.ts +++ b/js/src/graphql/auth.ts @@ -6,10 +6,6 @@ mutation Login($email: String!, $password: String!) { token, user { id, - }, - actor { - avatarUrl, - preferredUsername, } }, }