我读了很多关于Laravel中多认证的线程,我看到的大多数配置都有些复杂,我也看到过一个多认证包,但它不支持Laravel Socialite。
我知道这个问题被问了很多次,但如果有人能给出更好的答案。我将不胜感激!
我尝试过的事情
-
熟悉Laravel make:auth
-
我也熟悉Laravel社交网站Facebook, Twitter, Google plus。
试试吧。但是你仍然需要一些关于Laravel新多租户的基本知识。
-
在config/auth.php中添加
guards
数组:'customer' => [ 'driver' => 'session', 'provider' => 'customers', ],
-
然后在同一个文件中添加这个到
providers
数组:'customers' => [ 'driver' => 'eloquent', 'model' => App'Customer::class, ],
-
为
customers DB table
创建迁移(您可以使用Laravel的开箱即用迁移用户表) -
下一个是Eloquent模型
App'Customer
,包括:use App'Scopes'AuthorizedScope; use Illuminate'Foundation'Auth'User as Authenticatable;
这些应该可以让你在应用程序中使用Laravel的Auth facade和这些最常用的方法:
Auth::guard('customer')->attempt()
Auth::guard('customer')->check()
Auth::guard('customer')->logout()
Auth::guard('customer')->user()
或者像这样使用认证中间件:
Route::get('customer/dashboard', function () {
// Only authenticated users may enter...
})->middleware('auth:customer');
https://laravel.com/docs/5.3/authentication用户身份验证