Closed lightvision closed 9 years ago
Sorry I'm not sure what you mean, can you please clarify?
Sure. In the App\Http\Kernel.php there are the $routeMiddleware defined:
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
];
Before enabling the Dingo\Api php artisan route:list
show the middleware by its name: guest, auth.basic and so on.
After enabling the Dingo\Api the same commands show the middleware by its class: App\Http\Middleware\RedirectIfAuthenticated instead of guest
can confirm this; sample output from php artisan route:list
Domain | Method | URI | Name | Action | Middleware |
---|---|---|---|---|---|
GET/HEAD | login | pxcms.user.login | Cms\Modules\Auth\Http\Controllers\Frontend\Auth\AuthController@getLogin | Cms\Http\Middleware\RedirectIfAuthenticated | |
POST | login | Cms\Modules\Auth\Http\Controllers\Frontend\Auth\AuthController@postLogin | Cms\Http\Middleware\RedirectIfAuthenticated | ||
GET/HEAD | register | pxcms.user.register | Cms\Modules\Auth\Http\Controllers\Frontend\Auth\AuthController@getRegister | Cms\Http\Middleware\RedirectIfAuthenticated | |
POST | register | Cms\Modules\Auth\Http\Controllers\Frontend\Auth\AuthController@postRegister | Cms\Http\Middleware\RedirectIfAuthenticated | ||
GET/HEAD | registered | pxcms.user.registered | Cms\Modules\Auth\Http\Controllers\Frontend\Auth\AuthController@getRegistered | Cms\Http\Middleware\RedirectIfAuthenticated | |
GET/HEAD | user | pxcms.user.dashboard | Cms\Modules\Auth\Http\Controllers\Frontend\ControlPanel\DashboardController@getIndex | ||
GET/HEAD | u/{auth_user} | pxcms.user.view | Cms\Modules\Auth\Http\Controllers\Frontend\ControlPanel\DashboardController@getProfile | ||
GET/HEAD | admin/users/add | admin.user.add | Cms\Modules\Auth\Http\Controllers\Backend\UserManagerController@userManager | auth.admin,hasPermission | |
POST | admin/users | Cms\Modules\Auth\Http\Controllers\Backend\UserManagerController@userManager | auth.admin,hasPermission | ||
GET/HEAD | admin/users | admin.user.manager | Cms\Modules\Auth\Http\Controllers\Backend\UserManagerController@userManager | auth.admin,hasPermission |
I can't reproduce. Can you reproduce in a fresh install of L5.1 with the latest Dingo and share the routes file that causes this.
I've been unable to reproduce this through a few avenues of testing. If this is still an issue let me know and please provide some code so as I can properly reproduce it. Going to close for now.
I also faced this situation, and reproduce this.
First, I run the command to initiate laravel 5.1.4:
composer create-project laravel/laravel --prefer-dist
composer require dingo/api
Then add the content to 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::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');
// Password reset link request routes...
Route::get('password/email', 'Auth\PasswordController@getEmail');
Route::post('password/email', 'Auth\PasswordController@postEmail');
// Password reset routes...
Route::get('password/reset/{token}', 'Auth\PasswordController@getReset');
Route::post('password/reset', 'Auth\PasswordController@postReset');
Route::post('password/change', 'Auth\PasswordController@postChange');
After added, run php artisan route:list
output:
+--------+----------+------------------------+------+---------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+------------------------+------+---------------------------------------------------------+------------+
| | GET|HEAD | / | | Closure | |
| | GET|HEAD | auth/login | | App\Http\Controllers\Auth\AuthController@getLogin | guest |
| | POST | auth/login | | App\Http\Controllers\Auth\AuthController@postLogin | guest |
| | GET|HEAD | auth/logout | | App\Http\Controllers\Auth\AuthController@getLogout | |
| | GET|HEAD | auth/register | | App\Http\Controllers\Auth\AuthController@getRegister | guest |
| | POST | auth/register | | App\Http\Controllers\Auth\AuthController@postRegister | guest |
| | POST | password/change | | App\Http\Controllers\Auth\PasswordController@postChange | guest |
| | GET|HEAD | password/email | | App\Http\Controllers\Auth\PasswordController@getEmail | guest |
| | POST | password/email | | App\Http\Controllers\Auth\PasswordController@postEmail | guest |
| | POST | password/reset | | App\Http\Controllers\Auth\PasswordController@postReset | guest |
| | GET|HEAD | password/reset/{token} | | App\Http\Controllers\Auth\PasswordController@getReset | guest |
+--------+----------+------------------------+------+---------------------------------------------------------+------------+
It seems normal. But after adding Dingo\Api\Provider\LaravelServiceProvider::class,
to app.php providers, then run php artisan route:list
,output:
+--------+----------+------------------------+------+---------------------------------------------------------+---------------------------------------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+------------------------+------+---------------------------------------------------------+---------------------------------------------+
| | GET|HEAD | / | | Closure | |
| | GET|HEAD | auth/login | | App\Http\Controllers\Auth\AuthController@getLogin | App\Http\Middleware\RedirectIfAuthenticated |
| | POST | auth/login | | App\Http\Controllers\Auth\AuthController@postLogin | App\Http\Middleware\RedirectIfAuthenticated |
| | GET|HEAD | auth/logout | | App\Http\Controllers\Auth\AuthController@getLogout | |
| | GET|HEAD | auth/register | | App\Http\Controllers\Auth\AuthController@getRegister | App\Http\Middleware\RedirectIfAuthenticated |
| | POST | auth/register | | App\Http\Controllers\Auth\AuthController@postRegister | App\Http\Middleware\RedirectIfAuthenticated |
| | POST | password/change | | App\Http\Controllers\Auth\PasswordController@postChange | App\Http\Middleware\RedirectIfAuthenticated |
| | GET|HEAD | password/email | | App\Http\Controllers\Auth\PasswordController@getEmail | App\Http\Middleware\RedirectIfAuthenticated |
| | POST | password/email | | App\Http\Controllers\Auth\PasswordController@postEmail | App\Http\Middleware\RedirectIfAuthenticated |
| | POST | password/reset | | App\Http\Controllers\Auth\PasswordController@postReset | App\Http\Middleware\RedirectIfAuthenticated |
| | GET|HEAD | password/reset/{token} | | App\Http\Controllers\Auth\PasswordController@getReset | App\Http\Middleware\RedirectIfAuthenticated |
+--------+----------+------------------------+------+---------------------------------------------------------+---------------------------------------------+
As light vision said, App\Http\Middleware\RedirectIfAuthenticated instead of guest
php artisan route:list
displays the class name of the middleware instead of the middleware name when Dingo/Api is enabled.