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

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

laravel auth()->attempt() 是否寫任何會話

laravel auth()->attempt() 是否寫任何會話

PHP
揚帆大魚 2022-12-23 14:37:45
我?guī)讉€月前才學(xué)習(xí) Laravel。我想知道一個小問題。我使用 auth()->attempt() 成功進行了身份驗證。Laravel 是否自動添加任何 session() 變量?如果沒有,是需要自己添加session變量,還是需要在某處設(shè)置。, 非常感謝你!這是我的控制器的一部分    if (!$check = auth()->attempt([      'member_username' => request()->$input('username'),      'password' => request()->$input('pwd'),      'login_enable' => 1    ])){      //processing login successfully    }這是 web.php 的一部分Route::group(['middleware' => 'auth'], function(){// Login successfully route});這是 auth.php 的一部分    'guards' => [        'web' => [            'driver' => 'session',            'provider' => 'account',        ],        'api' => [            'driver' => 'token',            'provider' => 'users',        ],    ],    'providers' => [        'users' => [            'driver' => 'eloquent',            'model' => App\User::class,        ],        'account' => [          'driver' => 'eloquent',          'model' => App\Entity\AccountMain ::class,                ],    ],
查看完整描述

1 回答

?
墨色風(fēng)雨

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

當(dāng)您的守衛(wèi)身份驗證為session時,它使用Illuminate\Auth\SessionGuard該類。你可以在這里看到它的attempt方法:


/**

     * Attempt to authenticate a user using the given credentials.

     *

     * @param  array  $credentials

     * @param  bool  $remember

     * @return bool

     */

    public function attempt(array $credentials = [], $remember = false)

    {

        $this->fireAttemptEvent($credentials, $remember);


        $this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);


        // If an implementation of UserInterface was returned, we'll ask the provider

        // to validate the user against the given credentials, and if they are in

        // fact valid we'll log the users into the application and return true.

        if ($this->hasValidCredentials($user, $credentials)) {

            $this->login($user, $remember);


            return true;

        }


        // If the authentication attempt fails we will fire an event so that the user

        // may be notified of any suspicious attempts to access their account from

        // an unrecognized user. A developer may listen to this event as needed.

        $this->fireFailedEvent($user, $credentials);


        return false;

    }

你可以看到它調(diào)用了login這個守衛(wèi)的方法


/**

     * Log a user into the application.

     *

     * @param  \Illuminate\Contracts\Auth\Authenticatable  $user

     * @param  bool  $remember

     * @return void

     */

    public function login(AuthenticatableContract $user, $remember = false)

    {

        $this->updateSession($user->getAuthIdentifier());


        // If the user should be permanently "remembered" by the application we will

        // queue a permanent cookie that contains the encrypted copy of the user

        // identifier. We will then decrypt this later to retrieve the users.

        if ($remember) {

            $this->ensureRememberTokenIsSet($user);


            $this->queueRecallerCookie($user);

        }


        // If we have an event dispatcher instance set we will fire an event so that

        // any listeners will hook into the authentication events and run actions

        // based on the login and logout events fired from the guard instances.

        $this->fireLoginEvent($user, $remember);


        $this->setUser($user);

    }

電話就是您的updateSession答復(fù)。


查看完整回答
反對 回復(fù) 2022-12-23
  • 1 回答
  • 0 關(guān)注
  • 137 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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