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

Laravel 5.3 密碼代理自定義

Laravel 5.3 Password Broker Customization(Laravel 5.3 密碼代理自定義)
本文介紹了Laravel 5.3 密碼代理自定義的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

有誰知道如何覆蓋 Laravel 的密碼代理中使用的功能?我知道文檔:

Does anyone know how to override the functions used within laravel's password broker? I know the docs:

https://laravel.com/docs/5.3/passwords#resetting-views

提供有關(guān)如何處理視圖和一些表面級別的事情的信息,但實際上根本不清楚,或者我可能沒有閱讀足夠的時間.

Give information on what to do for things like views and a few surface level things but it's not clear at all really or maybe I'm not reading it enough times.

我已經(jīng)知道如何覆蓋 ResetsPasswords.php Trait 但覆蓋 Password::broker() 的功能是為了下一層.

I already know how to override the ResetsPasswords.php Trait but overriding the functionality of the Password::broker() is for the next layer in.

如果需要更多信息,我可以提供一些.

If there is more information needed I can kindly provide some.

提前致謝.

推薦答案

我不得不面對同樣的問題,需要重寫一些 PasswordBroker 函數(shù).經(jīng)過在網(wǎng)絡(luò)上的大量調(diào)查和許多失敗的嘗試,我最終實現(xiàn)了以下實現(xiàn):

I had to face the same issue, needed to override some of the PasswordBroker functions. After a lot of investigation on the web and many failed attempts to do so, I ended up to the following implementation:

  1. 在 AppProviders 中創(chuàng)建了一個 CustomPasswordResetServiceProvider,我在其中注冊了一個 CustomPasswordBrokerManager 實例.

  1. Created a CustomPasswordResetServiceProvider inside AppProviders where I registered a CustomPasswordBrokerManager instance.

namespace AppProviders;
use IlluminateSupportServiceProvider;
use AppServicesCustomPasswordBrokerManager; 
class CustomPasswordResetServiceProvider extends ServiceProvider{
    protected $defer = true;

    public function register()
    {
        $this->registerPasswordBrokerManager();
    }

    protected function registerPasswordBrokerManager()
    {
        $this->app->singleton('auth.password', function ($app) {
            return new CustomPasswordBrokerManager($app);
        });
    }

    public function provides()
    {
        return ['auth.password'];
    }
}

  • config/app.php 中注釋掉一行:
    //IlluminateAuthPasswordsPasswordResetServiceProvider::class,
    并補充說:
    AppProvidersCustomPasswordResetServiceProvider::class,

    Inside AppServices 文件夾創(chuàng)建了一個 CustomPasswordBrokerManager 并復(fù)制了位于以下位置的默認 PasswordBrokerManager 的上下文:
    IlluminateAuthPasswordsPasswordBrokerManager.php
    然后修改函數(shù) resolve 以返回我的 CustomPasswordProvider 類的實例.

    Inside AppServices folder created a CustomPasswordBrokerManager and copied the context of the default PasswordBrokerManager located at:
    IlluminateAuthPasswordsPasswordBrokerManager.php
    Then modified the function resolve to return an instance of my CustomPasswordProvider class.

    protected function resolve($name)
    {
        $config = $this->getConfig($name);
        if (is_null($config)) {
            throw new InvalidArgumentException("Password resetter [{$name}] is not defined.");
        }
    
        return new CustomPasswordBroker(
            $this->createTokenRepository($config),
            $this->app['auth']->createUserProvider($config['provider'])
    );
    }
    

  • 最后在 AppServices 文件夾中,我創(chuàng)建了一個 CustomPasswordBroker 類,它擴展了位于以下位置的默認 PasswordBroker:
    IlluminateAuthPasswordsPasswordBroker 并覆蓋我需要的功能.

  • Finally inside AppServices folder I created a CustomPasswordBroker class which extends default PasswordBroker located at:
    IlluminateAuthPasswordsPasswordBroker and overridden the functions that I needed.

    use IlluminateAuthPasswordsPasswordBroker as BasePasswordBroker;    
    
    class CustomPasswordBroker extends BasePasswordBroker    
    {    
    // override the functions that you need here    
    }      
    

  • 不確定這是否是最好的實現(xiàn),但它對我有用.

    Not sure if this is the best implementation but it worked for me.

    這篇關(guān)于Laravel 5.3 密碼代理自定義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 重定向到登錄頁面)
    主站蜘蛛池模板: 人人九九精 | 国产综合视频 | 国产精品久久久久久模特 | 日韩欧美国产精品一区 | 免费国产视频 | 欧美在线视频a | 亚洲视频 欧美视频 | 久久精品亚洲一区 | 国产黄色在线观看 | 欧美日韩国产在线观看 | 国产精品久久久久久久久久久久久 | 国产精品黄色 | 亚洲精品一区二区另类图片 | 综合五月婷 | 欧美精品1区 | www.日本在线观看 | 亚洲丝袜天堂 | 国产成人小视频 | 久久噜噜噜精品国产亚洲综合 | 亚洲情综合五月天 | 国产成人综合在线 | 欧美一区二区在线观看 | 亚洲久在线 | 免费成人高清在线视频 | 天天综合网永久 | 国产精品久久国产精品99 gif | 麻豆hd| 最近中文字幕第一页 | 国产9999精品 | 久久高清 | 亚洲 中文 欧美 日韩 在线观看 | 国产探花在线精品一区二区 | 精品国产欧美 | 亚洲第一视频 | 久久久一| 超碰人人插 | 国产精品久久欧美久久一区 | 欧美日韩中文字幕 | 久久精品国产亚洲a | 国产精品久久久久久久久久免费看 | 天堂在线www |