简体   繁体   English

Laravel 5管理面板身份验证

[英]Laravel 5 Admin Panel Authentication

ast week I started studying laravel 5 and it was fun. 上周我开始学习laravel 5,这很有趣。

I want to build a website that has a frontend and a backend (admin panel). 我想建立一个具有前端和后端的网站(管理面板)。 I separated the controllers and views of admin panel. 我分离了控制器和管理面板的视图。 Backend is accesible via route: admin/* 可以通过以下途径访问后端:admin / *

But I have a problem separating Auth. 但是我在分离Auth时遇到问题。 I have a user table for the frontend and separate table for users in the backend, because frontend and backend user table has totally different structures. 我有一个用于前端的用户表和一个用于后端用户的单独表,因为前端和后端用户表的结构完全不同。

Here's my code in my routes.php: 这是我的routes.php中的代码:

Route::group(['prefix' => 'admin', 'namespace' => 'admin'], function(){
    Route::get('custom-url', 'TestController@index');

    Route::controllers([
        'auth'      => 'Auth\AuthController',
        'password'  => 'Auth\PasswordController',
    ]);

});


Route::resource('articles', 'ArticlesController');

Route::controllers([
    'auth'      => 'Auth\AuthController',
    'password'  => 'Auth\PasswordController',
]);

Here's my folder structure: 这是我的文件夹结构:

在此处输入图片说明

在此处输入图片说明

If you are having different user accounts for frontend and backend then it is like 2 different applications where you have to implement authentication on your own. 如果您为前端和后端使用不同的用户帐户,则就像两个不同的应用程序一样,您必须自己实施身份验证。 Fortunately it is not too difficult. 幸运的是这并不困难。

I would recommend to have user roles instead. 我建议改为使用用户角色。 Have only minimal info in users table that is shared and have additional information table for each role. 在共享的用户表中只有很少的信息,并且每个角色都有其他信息表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM