首页 文章

Laravel登录后找不到所有路线

提问于
浏览
0

我正在开发laravel项目,并且对于公共用户来说,每件事情都可以正常工作,但是一旦用户登录了所有页面变得无法访问,即使是公共页面也找不到404页面 .
如果我删除cookie,公共页面将再次可访问 .

这是我的登录功能:

try{
            if (Auth::validate($userdata)) {
                if (Auth::attempt($userdata)) {
                    // TODO check if is admin Role
                    $user = Auth::user()->getParseUser();
                    if ($user->get('isAdmin'))
                        return Redirect::intended('/');
                    else {
                        Auth::logout(); // logout user
                        return Redirect::back()->with('error', "Access denied");
                    }
                }
            } else {
                // if any error send back with message.
                return Redirect::back()->with('error', 'invalid login parameters ');
            }
        } catch (ParseException  $ex) {
            // if any error send back with message.
            if ($ex->getCode() == 101)
                return Redirect::back()->with('error', 'invalid login parameters');
            else
                return Redirect::back()->with('error', 'Please contact the admin');
        }

路线文件:

Route::get('/', 'PublicController@index');

Route::get('/product/{id}','PublicController@details');

Route::get('login', 'PublicController@login');
Route::post('login', 'PublicController@loginAction');

Route::get('logout', function(){
    Auth::logout(); // logout user
    return Redirect::to('/');
});


Route::delete('product/{id}', ['middleware' => 'auth', 'uses' =>'AnnounceController@destroy']);
Route::delete('product/comment/{id}', ['middleware' => 'auth', 'uses' =>'AnnounceController@destroyComment']);

1 回答

  • 1

    检查PublicController.php文件以获取隐式中间件 .

    中间件只有两个可能的位置:

    • routes.php;

    • 控制器;

    你的问题描述指向那个方向 .

相关问题