Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sentinel和Laravel 5.2_Laravel_Authentication_Sentinel - Fatal编程技术网

Sentinel和Laravel 5.2

Sentinel和Laravel 5.2,laravel,authentication,sentinel,Laravel,Authentication,Sentinel,我不能让哨兵工作。我不知道该怎么办了,我什么都试过了,希望别人能给我一些建议。 问题是在线中间件中的检查方法为false 编辑:我发现问题是会话在中间件中不起作用,仍然没有解决方案 EDIT2:看起来像它的许可证,我在ubuntu上,我在win10上运行了与xampp相同的代码,一切都很好,仍然没有ubuntu的解决方案 routes.php Route::group(['middleware' => ['web']], function () { Route::get('/',

我不能让哨兵工作。我不知道该怎么办了,我什么都试过了,希望别人能给我一些建议。 问题是在线中间件中的检查方法为false

编辑:我发现问题是会话在中间件中不起作用,仍然没有解决方案

EDIT2:看起来像它的许可证,我在ubuntu上,我在win10上运行了与xampp相同的代码,一切都很好,仍然没有ubuntu的解决方案

routes.php

Route::group(['middleware' => ['web']], function () {

Route::get('/',          ['as' => 'index'    , 'uses' => 'UserController@index']);
Route::post('login',     ['as' => 'login'    , 'uses' => 'UserController@login']);
Route::post('register',  ['as' => 'register' , 'uses' => 'UserController@register']);
Route::get('logout',    ['as' => 'logout'   , 'uses' => 'UserController@logout']);

Route::group(['prefix' => 'viva' , 'middleware' => ['online']], function () {
    Route::get('/',     ['as' => 'dashboard'    , 'uses' => 'VivaController@dashboard']);
});
});
登录方法

public function login(){
    $data = Input::all();

    $credentials = [
        'email'    => $data["username"],
        'password' => $data["password"],
    ];

    $user = Sentinel::authenticate($credentials);

    if (!empty($user)){
        Sentinel::login($user);
        //dd(Sentinel::check()); //---> this gives logged user...
        return Redirect::route('dashboard');
    }
    else{
        return Redirect::back()->withErrors(['fail', 'Neuspjela prijava! Molimo pokušajte ponovo.']);
    }


}
online.php中间件

 class online
{
/**
 * Handle an incoming request.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @return mixed
 */
public function handle($request, Closure $next )
{
    dd(Sentinel::check()); //---> this is always false


    if (Sentinel::check())
    {
        return Redirect::route('dashboard');
    }
    else
    {
        return Redirect::route('index')->withErrors(['fail', 'Nemate prava na pristup ovim stranicama!']);
    }

    return $next($request);

}
}

对于会话,我相信您可能需要这些权限

注:假设Laravel安装在
/var/www/Laravel


对于会话,我相信您可能需要这些权限

注:假设Laravel安装在
/var/www/Laravel

cd /var/www/laravel
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache