Fix login
This commit is contained in:
parent
f0026a8783
commit
1a6869c3ff
@ -110,24 +110,25 @@
|
|||||||
this.credentials.password = this.password;
|
this.credentials.password = this.password;
|
||||||
}
|
}
|
||||||
|
|
||||||
loginAction(e: Event) {
|
async loginAction(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
this.$apollo.mutate({
|
try {
|
||||||
mutation: LOGIN,
|
const result = await this.$apollo.mutate({
|
||||||
variables: {
|
mutation: LOGIN,
|
||||||
email: this.credentials.email,
|
variables: {
|
||||||
password: this.credentials.password,
|
email: this.credentials.email,
|
||||||
},
|
password: this.credentials.password,
|
||||||
}).then((result) => {
|
},
|
||||||
console.log(result)
|
});
|
||||||
|
|
||||||
this.saveUserData(result.data);
|
this.saveUserData(result.data);
|
||||||
this.$router.push({ name: 'Home' });
|
this.$router.push({ name: 'Home' });
|
||||||
}).catch((e) => {
|
} catch (err) {
|
||||||
console.log(e);
|
console.error(err);
|
||||||
this.error.show = true;
|
this.error.show = true;
|
||||||
this.error.text = e.message;
|
this.error.text = err.message;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
validEmail() {
|
validEmail() {
|
||||||
@ -136,7 +137,6 @@
|
|||||||
|
|
||||||
saveUserData({ login: login }) {
|
saveUserData({ login: login }) {
|
||||||
localStorage.setItem(AUTH_USER_ID, login.user.id);
|
localStorage.setItem(AUTH_USER_ID, login.user.id);
|
||||||
localStorage.setItem(AUTH_USER_ACTOR, JSON.stringify(login.actor));
|
|
||||||
localStorage.setItem(AUTH_TOKEN, login.token);
|
localStorage.setItem(AUTH_TOKEN, login.token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,6 @@ mutation Login($email: String!, $password: String!) {
|
|||||||
token,
|
token,
|
||||||
user {
|
user {
|
||||||
id,
|
id,
|
||||||
},
|
|
||||||
actor {
|
|
||||||
avatarUrl,
|
|
||||||
preferredUsername,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user