我正在为我的应用程序使用Laravel 5的auth模块。然而,在我使用php artisan make:auth创建auth函数后,我只能访问两个路径:/ login和/ register,无论我如何在routes.php中添加路由。所有其他路径将我重定向到登录页面。如何在不记录的情况下使用户能够访问某些路径?感谢。
routes.php文件:
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::auth();
Route::get('/home', 'HomeController@index');
Route::get('/patient', 'HomeController@registerPatient');
Route::get('test', 'HomeController@index');
Route::group(array('before' =>'auth'), function()
{
Route::get('about', array('as' => 'about','uses' => 'HomeController@about'));
}
);
Route::group(array('before' =>'auth'), function()
{
Route::get('/physician', array('as' => 'physician','uses' => 'HomeController@registerPhysician'));
}
);
答案 0 :(得分:1)
你能分享你的控制器代码吗?我的意思是你在你的控制器构造中有auth中间件吗?
LinkedList& operator+=(const LinkedList& _list) {
Node* temp = _list.head;
while (temp != nullptr) {
insert(temp->data);
temp = temp->next;
}
return *this;
}
无论如何检查homecontrolle中的ur构造方法并将auth middlewere仅应用于某些方法
为例
Route::group(['middleware' => 'web'], function () {
Route::auth();
Route::get('/', function () {
return view('welcome');
});
Route::get('/home', 'HomeController@index');
Route::get('/patient', 'HomeController@registerPatient');
Route::get('test', 'HomeController@index');
});
Route::group(array('before' =>'auth'), function()
{
Route::get('/physician', array('as' => 'physician','uses' => 'HomeController@registerPhysician'));
Route::get('about', array('as' => 'about','uses' => 'HomeController@about'));
}
);