Laravel 5.2: 授权路由在哪里声明?

Laravel 5.2: where are auth routes declared?

我需要重新排列授权系统使用的 url。 Laravel 5.2。 我使用了 artisan make:auth,但现在我找不到告诉路由器如何处理 /login/logout 的位置。恕我直言,在我看来,'ease of use' Laravel 的努力是倒退了一步,因为在最近的修订中,如此多的通常被覆盖的功能应该变得如此模糊。

我将应用程序划分为管理和 public 区域,每个区域都有单独的登录机制:/admin/login 将由核心 Laravel 系统处理和 /login 将用于前端管理员用户,由另一组 类 处理身份验证。

有人可以告诉我吗?

php artisan make:auth 将以下行添加到您的路线文件中:

Route::group(['middleware' => 'web'], function () {
    Route::auth();
}

Route::auth() 是定义以下路由的快捷方式:

// Authentication Routes...
$this->get('login', 'Auth\AuthController@showLoginForm');
$this->post('login', 'Auth\AuthController@login');
$this->get('logout', 'Auth\AuthController@logout');

// Registration Routes...
$this->get('register', 'Auth\AuthController@showRegistrationForm');
$this->post('register', 'Auth\AuthController@register');

// Password Reset Routes...
$this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
$this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
$this->post('password/reset', 'Auth\PasswordController@reset');

所以假设你 运行 auth:make 并且没有接触任何东西,这些就是你可以使用的路线。

来源:https://mattstauffer.co/blog/the-auth-scaffold-in-laravel-5-2#routeauth

您需要构建 2 个系统,一个用于 public,一个用于管理员。

Jeffrey Way (Laracast) 制作了一段视频,解释了构建完整的自定义登录系统所需的一切,该系统与您从 artisan make:auth 获得的一样。

视频 link 是 https://laracasts.com/lessons/email-verification-in-laravel. The video is not free, but Jeffrey has the code available on this git (https://github.com/laracasts/Email-Verification-In-Laravel)。

我用它用同一个数据库构建了两个独立的系统。

注意:link在Laravel中称为邮箱验证,但它涵盖了验证的所有内容。

您只需更改路径的两个参数。

protected $redirectPath = '/dashboard';

当用户成功通过身份验证后,他们将被重定向到此路径。

第二个是登录路径。您可以通过在 AuthController 上定义登录路径 属性 来自定义失败的 post-身份验证重定向位置:

protected $loginPath = '/login';