第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何配置用戶登錄時禁止更多最大嘗試次數(shù)?

如何配置用戶登錄時禁止更多最大嘗試次數(shù)?

PHP
慕無忌1623718 2023-08-26 17:42:04
我在 Laravel 7 工作我根據(jù)需要調(diào)整loginController;最大嘗試次數(shù)和衰減分鐘數(shù)public function maxAttempts(){        return General::first()->max_attempts;}public function decayMinutes(){        return General::first()->decay_minutes;}如何禁止用戶超過 maxAttempts示例 => 最大嘗試次數(shù) = 4我想禁止用戶嘗試失敗 5 次$user->is_block = true
查看完整描述

2 回答

?
動漫人物

TA貢獻1815條經(jīng)驗 獲得超10個贊

您將需要為用戶創(chuàng)建一個列來計算他們不成功的登錄嘗試。每次不成功的嘗試時,您都會增加該值,并在達到特定限制時阻止用戶。

如果登錄成功,則將計數(shù)器設(shè)置為0。


查看完整回答
反對 回復(fù) 2023-08-26
?
絕地無雙

TA貢獻1946條經(jīng)驗 獲得超4個贊

我測試了一下,是正確的。


首先在您的EventServiceProvider 中創(chuàng)建兩個事件偵聽器。 登錄成功和登錄失敗

protected $listen = [

        Registered::class => [

            SendEmailVerificationNotification::class,

        ],

        'Illuminate\Auth\Events\Login' => [

            'App\Listeners\SuccessfulLogin',

        ],


        'Illuminate\Auth\Events\Failed' => [

            'App\Listeners\FailedLogin',

        ],

    ];

在成功登錄中:

public function handle(Login $event)

    {

        

        $event->user->user_last_login_date = Carbon::now();

        $event->user->unsuccessful_login_count = 0;

        $event->user->save();


    }

在登錄失敗中:

$event->user->unsuccessful_login_count += 1 ;

        $unsuccessful_count =   General::first()->max_attempts;


        if ($event->user->unsuccessful_login_count == $unsuccessful_count ) {

            $event->user->three_attempt_timestamp = Carbon::now()->toDateString();

        }

        if ($event->user->unsuccessful_login_count > $unsuccessful_count ) {

            $event->user->is_block = 1;

        }


        $event->user->save();


查看完整回答
反對 回復(fù) 2023-08-26
  • 2 回答
  • 0 關(guān)注
  • 210 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號