Full-Stack Web Development with Vue.js and Node

(singke) #1

Building Authentication with passport.js Chapter 6


Register
</v-btn>
<v-btn flat v-bind:to="{ name: 'Login' }" v-if="!current_user"
id="login_btn">Login</v-btn>
<v-btn id="logout_btn" flat v-if="current_user"
@click="logout">Logout</v-btn>
</v-toolbar-items>
</v-toolbar>
<v-content>
<v-container fluid>
<div id="app">
<router-view/>
</div>
</v-container>
</v-content>
<v-footer color="indigo" app>
<span class="white--text">© 2018</span>
</v-footer>
</v-app>
</template>

<script>
import axios from 'axios';

import './assets/stylesheets/main.css';
import bus from './bus';

export default {
data: () => ({
drawer: null,
current_user: null,
}),
props: {
source: String,
},
mounted() {
this.fetchUser();
this.listenToEvents();
},
methods: {
listenToEvents() {
bus.$on('refreshUser', () => {
this.fetchUser();
});
},
async fetchUser() {
return axios({
method: 'get',
Free download pdf