在Vue中使用LoginController.php

时间:2018-07-09 17:58:14

标签: php laravel vue.js vuetify.js

我正在使用Vue和Laravel。在遵循Jwt-auth之前,我一直遵循这些说明(PHP docs)。

截至目前,如果我尝试去任何/login路线,我都会被引导到auth: true。当我使用不正确的凭据并单击登录时,它不会尝试重定向,这很好,但是当我输入正确的凭据时,它会尝试按照LoginController中的指定直接定向到/,但随后又回到{{ 1}}。我认为我正在通过/login路线看到auth: true,并且不知如何获得了我的授权。我该如何解决?如何确保/满意并坚持贯穿整个浏览器?

auth: true

这是我的Login.vue

App.js 

/** 

* First we will load all of this project's JavaScript dependencies which 

* includes Vue and other libraries. It is a great starting point when 

* building robust, powerful web applications using Vue and Laravel. 

*/




require('./bootstrap');




window.Vue = require('vue');




import Vuetify from 'vuetify'

import VueRouter from 'vue-router'

import axios from 'axios'

import VueAxios from 'vue-axios'


import Home from './components/home.vue';

import Users from './components/users.vue';

import Logs from './components/logs.vue';

import Settings from './components/settings.vue';

import Login from './components/login.vue';

import Google from './components/google.vue';


Vue.use(Vuetify)

Vue.use(VueRouter)

Vue.use(VueAxios, axios)


const routes = [

    {

        title: 'Home',

        icon: 'home',

        name: 'google',

        path: '/',

        component: Google,

        meta: {

            auth: true
        },

        children:

            [

                {

                    path: 'welcome',

                    name: 'welcome',

                    component: Home,

                    meta: {

                        auth: true
                    }

                },

                {

                    path: 'users',

                    name: 'users',

                    component: Users,

                    meta: {

                        auth: true
                    },

                },

                {

                    path: 'logs',

                    name: 'logs',

                    component: Logs,

                    meta: {

                        auth: true
                    }

                },

                {

                    path: 'settings',

                    name: 'settings',

                    component: Settings,

                    meta: {

                        auth: true
                    }

                },

            ]

    },

    {

        title: 'Login',

        icon: 'home',

        path: '/login',

        name: 'signin',

        component: Login,

        meta: {

            auth: false
        }

    }

]

const router = new VueRouter({

    routes: routes,

    linkActiveClass: 'list_tile--active',

    mode: 'history',

});


Vue.router = router
Vue.use(require('@websanova/vue-auth'), {
    auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
    http: require('@websanova/vue-auth/drivers/http/axios.1.x.js'),
    router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
 });



/** 

* Next, we will create a fresh Vue application instance and attach it to 

* the page. Then, you may begin adding components to this application 

* or customize the JavaScript scaffolding to fit your unique needs. 

*/



const app = new Vue({

    el: '#app',

    components: {

        google: require('./components/google.vue')

    },

    data() {

        return {

            routes: routes,

        }

    },

    router,

});

0 个答案:

没有答案