"未认证"未受保护的路由上的错误

时间:2017-08-08 14:55:16

标签: laravel laravel-5.4 laravel-passport

我的部分应用程序不使用标准用户身份验证,位于我的路由文件中的auth组之外。我正在使用Laravel Passport,VueJS2,VueRouter。 Laravel正在提供两个刀片文件;一个用于应用程序的已认证部分,另一个用于未经认证的部分。

但是,我发现在尝试访问应用程序的那一部分时,仍然需要我进行身份验证(我得到401:未经授权的错误)。

我查看了我的配置文件,但我似乎无法弄清楚为什么会这样显示。

我的api.php文件:

/service-instances/frontend

发出请求的JS文件:

<?php

use Illuminate\Http\Request;


Route::group(['middleware' => 'auth'], function () {
// A lot of routes here...
});

// These should not be guarded
// This is the route that triggers the unauthenticated message
Route::post('authenticate', 'TestController@authenticate');

这是我的kernel.php文件:

authenticateUser: function() {
    var data = {
        'id' : this.$route.params.id,
        'passcode' : this.state.password,
    };

    var that = this;

    axios({
      method: 'post',
      url: '/api/authenticate',
      withCredentials: true,
      data: data,
    }).then(function(response) {
        swal('Great!', 'You have been authenticated.', 'success');
        that.$router.push('/client/create/' + that.$route.params.id);
    }, function(error) {
        swal('Woah!', 'Wrong password, go away.', 'error');
    });
}

0 个答案:

没有答案
相关问题