Fix login

This commit is contained in:
Chocobozzz 2018-12-28 16:17:34 +01:00
parent f0026a8783
commit 1a6869c3ff
2 changed files with 14 additions and 18 deletions

View File

@ -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);
}
}

View File

@ -6,10 +6,6 @@ mutation Login($email: String!, $password: String!) {
token,
user {
id,
},
actor {
avatarUrl,
preferredUsername,
}
},
}