【问题标题】:laravel redirection error after session out会话结束后laravel重定向错误
【发布时间】:2014-08-12 16:02:54
【问题描述】:

我在我的管理部分使用 laravel 4,它在正常情况下工作正常,但是当会话超时并且我刷新页面而不是它没有正确重定向时,我的管理员登录路径是

localhost/project_name/public/admin/login

当我正确注销它的重定向但是当自动会话退出而不是去管理/登录时,它重定向到以下路径

localhost/admin/login

所以任何人都可以告诉我这个的解决方案

【问题讨论】:

    标签: laravel laravel-4 session-timeout url-redirection


    【解决方案1】:

    @Deepak Goyal,

    在 routes.php 中定义一个前置过滤器来检查它,类似于:

    Route::group(["before" => "auth"], function ()
    {
    //rest of the authenticated routes goes here
    }
    

    在 filters.php 中

    Route::filter("auth", function()
    {
    
    if (Auth::guest()) return Redirect::guest("admin/login");
    
    });
    

    【讨论】:

    • 在我的 rotes.php 文件中我有代码 Route::group(array('prefix'=>'admin','before'=>'admin-auth'), function(){ Route::get('/','AdminController@index'); } 和 filter.php 文件中的 Route::filter('admin-auth', function(){ if(Auth::guest() || Auth: :user()->usertype == 'client' || Auth::user()->active == 0) return Redirect::to('admin/login?ret='.Request::url()); });
    • @Deepak Goyal,为 Auth::user()->usertype == 'client' 和 Auth::user()->active == 0 创建单独的过滤器。
    • @Deepak Goyal,只需替换 if(Auth::guest() || Auth::user()->usertype == 'client' || Auth::user()->active = = 0) 与 if (Auth::guest()) 并尝试
    • 我已经检查了这个方法,但问题仍然与我检查 URL 问题相同,我发现当我输入 localhost/project_name/public/admin 之类的 url 时,它工作正常但如果我使用像localhost / project_name / public / admin /这样的斜杠比出现问题所以请你帮我解决这个问题
    猜你喜欢
    • 2013-04-22
    • 2018-08-06
    • 2013-05-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-29
    • 1970-01-01
    • 1970-01-01
    • 2016-08-27
    相关资源
    最近更新 更多