久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 Laravel 中為 auth 控制器設(shè)置新的保護(hù)

how to set new guard for auth controller in laravel(如何在 Laravel 中為 auth 控制器設(shè)置新的保護(hù))
本文介紹了如何在 Laravel 中為 auth 控制器設(shè)置新的保護(hù)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我想在我的 Laravel 項目中進(jìn)行多重身份驗證.

I want to make multiple authentication in my laravel project.

我在 auth.php 文件中創(chuàng)建了新的守衛(wèi)admin",但我不知道如何在我的 authcontroller 中設(shè)置新創(chuàng)建的守衛(wèi).

I create new guard "admin" in my auth.php file but I don't know how to set new created guard in my authcontroller.

它總是使用我的 auth.php 中的默認(rèn)"設(shè)置:

It always use "defaults" settings from my auth.php:

'defaults' => [
    'guard' => 'web',
    'passwords' => 'users',
],

推薦答案

1) 如果您希望在整個應(yīng)用程序中使用新創(chuàng)建的 admin 保護(hù),您可以更改 defaults<中的值/strong> 的配置文件.

1) If you wish to use newly created admin guard throughout the application, you can change the value in defaults of config file.

2) 如果只有 AuthController 使用 Laravel 內(nèi)置的 Auth 系統(tǒng),你可以在 AuthController.phpPasswordController.php 中添加這一行 :

2) If it is only about AuthController that uses Laravel's in built Auth system, you can add this line in the AuthController.php and PasswordController.php :

protected $guard = 'admin';

Ref - 檢查 Guard 自定義 此處

3) 如果您希望為任何 Auth 相關(guān)任務(wù)設(shè)置一個非默認(rèn)值的守衛(wèi),您可以像這樣手動指定:

3) If you wish to you a guard other than default one for any Auth related task, you can specify it manually like this :

// For route middleware
Route::get('profile', [
    'middleware' => 'auth:admin',
    'uses' => 'ProfileController@show'
]);

// For manually logging the user in
if (Auth::guard('admin')->attempt($credentials)) {
    // Authenticated...
}

// To login specific user using eloquent model
Auth::guard('admin')->login($user);

// For getting logged in user
Auth::guard('admin')->user();

// To check if user is logged in
if (Auth::guard('admin')->check()) {
    // Logged in
}

參考 - https://laravel.com/docs/5.2/authentication

這篇關(guān)于如何在 Laravel 中為 auth 控制器設(shè)置新的保護(hù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

add new element in laravel collection object(在 Laravel 集合對象中添加新元素)
Creating an edit modal in Laravel 5(在 Laravel 5 中創(chuàng)建編輯模式)
Laravel 5.5 API resources for collections (standalone data)(用于集合的 Laravel 5.5 API 資源(獨立數(shù)據(jù)))
What is the best practice to create a custom helper function in php Laravel 5?(在 php Laravel 5 中創(chuàng)建自定義輔助函數(shù)的最佳實踐是什么?)
No #39;Access-Control-Allow-Origin#39; header - Laravel(沒有“Access-Control-Allow-Origin標(biāo)頭 - Laravel)
Laravel Passport Route redirects to login page(Laravel Passport Route 重定向到登錄頁面)
主站蜘蛛池模板: 久久国产高清 | 国产成人一区在线 | 欧美在线视频网 | 亚洲精品一区二三区不卡 | japan25hdxxxx日本| 国产一级免费视频 | 精品久久国产 | 精品网| 亚洲国产精品99久久久久久久久 | 中日av| 中文在线视频 | 精品免费 | 久久精品免费观看 | 天天爱av | 国产成人综合久久 | 欧美日韩一区精品 | 久久三级av | 欧美精品91爱爱 | 日韩av免费看 | 91欧美| 国产亚洲一区二区三区在线观看 | 中文字幕视频在线 | 免费视频一区二区三区在线观看 | 国产h在线 | 不卡一区 | 亚洲欧美激情精品一区二区 | 免费国产一区 | 日韩在线小视频 | 亚洲一区二区av | 日本不卡高字幕在线2019 | 亚洲高清av | 国产精品永久免费 | 天天天操天天天干 | 日韩快播电影网 | 国产精品嫩草影院精东 | 日韩播放| 九九热在线免费视频 | 国产精品一区二区三区四区 | 97高清国语自产拍 | 欧美爱爱视频网站 | 亚洲一区二区日韩 |