Feature: Add login-form with error-handling

This commit is contained in:
winkidney
2019-11-29 17:25:37 +08:00
committed by Isaac Bythewood
parent 58a0b663aa
commit 5d86ef1e1d
3 changed files with 113 additions and 1 deletions

View File

@@ -66,6 +66,7 @@
</a>
<a
v-show="!user.loggedIn"
v-on:click="logIn"
class="button is-light">
Log in
</a>
@@ -86,6 +87,7 @@
<script>
import api from './api';
import LoginForm from './LoginForm.vue';
export default {
name: 'p-header',
@@ -102,6 +104,9 @@ export default {
toggleMenu() {
this.active = !this.active;
},
onLoginSucceed() {
this.initializeUser();
},
logOut() {
api.User.logOut().then(
() => {
@@ -109,6 +114,16 @@ export default {
},
);
},
logIn() {
this.$buefy.modal.open({
parent: this,
component: LoginForm,
hasModalCard: true,
events: {
'login.succeed': this.onLoginSucceed,
},
});
},
initializeUser() {
const self = this;
api.User.fetchUserInfo().then(