2016-03-13 55 views
1

我在Laravel建立一个应用程序,我已经有我的用户注册工作正常,我现在想修改注册如何工作,所以我修改我的路线来调用不同的方法。Laravel post路由控制器方法没有被调用

原来的路线的定义,像这样:

Route::post('register', 'Auth\[email protected]'); 

这工作得很好。然后,我把它改为:

Route::post('register', 'Auth\[email protected]'); 

此方法定义如下:

public function someOtherMethod(Request $request) 
{ 
    die('If the method is called you should see this'); 
} 

然而,它不会被调用(该消息未显示)。相反,它会将我重定向到网站的根目录。

请注意,我有我的服务器,我跑我每次有这样奇怪的问题时,其运行以下命令的缓存清除脚本:在隐身

php artisan route:clear 
php artisan cache:clear 
service php5-fpm restart 
service nginx restart 

我也跑了页/私有每次我做出改变时都会出现窗口。

现在有趣的部分;我试着撤销我所做的更改,以便再次调用postRegister,我完全期望这会使其恢复为默认行为,但仍会将我重定向到网站的根目录!所以现在我甚至没有注册页面。

有没有人有任何想法是怎么回事?

在此先感谢您的帮助。

编辑:

这里是我的全routes.php

use Illuminate\Http\Request; 

Route::group(['middleware' => 'web'], function() { 
    /** Public routes **/ 
    Route::get('',        '[email protected]'); 
    Route::get('/',        '[email protected]'); 
    Route::get('terms', function() { 
     return view('terms'); 
    }); 
    Route::get('privacy', function() { 
     return view('privacy'); 
    }); 

    /** Public auth routes **/ 
    Route::get('register',      'Registr[email protected]'); 
    Route::post('register',      'Auth\[email protected]'); 
    Route::get('login', function() { 
     return view('auth.login'); 
    }); 
    Route::post('login',      'Auth\[email protected]'); 
    Route::get('logout',      'Auth\[email protected]'); 
    Route::get('dashboard/login', function() { 
     return view('admin.login'); 
    }); 
    Route::post('dashboard/login',    'AdminAuth\[email protected]'); 
    Route::get('dashboard/logout',    'AdminAuth\[email protected]'); 

    /** Admin routes **/ 
    Route::get('dashboard', [ 
     'middleware' => 'admin', 
     'uses' => 'Admin\[email protected]' 
    ]); 
    Route::get('dashboard/users', [ 
     'middleware' => 'admin', 
     'uses' => 'Admin\[email protected]' 
    ]); 
    Route::get('dashboard/search', [ 
     'middleware' => 'admin', 
     'as' => 'adminSearch', 
     'uses' => 'Admin\[email protected]' 
    ]); 

    /** Admin auth routes **/ 
    Route::get('dashboard/staff/create', [ 
     'middleware' => 'admin', 
     function() { 
      return view('admin.register'); 
     } 
    ]); 
    Route::post('dashboard/staff/create', [ 
     'middleware' => 'admin', 
     'uses' => 'AdminAuth\[email protected]' 
    ]); 

    /** Controllers **/ 
    Route::controllers([ 
     'password' =>       'Auth\PasswordController', 
    ]); 
}); 
+1

击中你的注销网址一次,然后再试一次? –

+0

是的,我也是这么做的。此外,正如我所提到的,每当我尝试这样做时都会打开一个新的隐身/私人窗口,因此登录不应该成为问题。 –

+0

你在哪里放置这条路线?在'web'中间件之外。对? –

回答

0

确保你的config/auth.php呼吁正确验证后卫。另外redirectsTo默认设置为“/”,这是网站的路由。你的中间件是什么?默认的RedirectIfAuthenticated中间件默认具有指向站点根目录的条目。只有这3种情况可能不是预期的。