Extending Laravel 5.2 SessionGuard

后端 未结 1 1971
粉色の甜心
粉色の甜心 2020-12-18 05:55

I want to extend the Laravel stock authentication to use an OAuth server for user retrieval and authentication while taking advantage of the existing functionality. I alread

1条回答
  •  臣服心动
    2020-12-18 06:29

    Recently I've had the same problem, so maybe the solution is something like this.

    updateSession($user->getAuthIdentifier());
            if ($remember) {
                $this->refreshRememberToken($user);
                $this->queueRecallerCookie($user);
            }
            $this->fireLoginEvent($user, $remember);
            $this->setUser($user);
        }
    }
    

    In AppServiceProvider.php

    public function boot()
    {
        Auth::extend(
            'sessionExtended',
            function ($app) {
                $provider = new EloquentUserProvider($app['hash'], config('auth.providers.users.model'));
                return new SessionGuardExtended('sessionExtended', $provider, app()->make('session.store'), request());
            }
        );
    }
    

    In Config/auth.php driver should be renamed

    'web' => [
        'driver' => 'sessionExtended',
        'provider' => 'users',
    ],
    

    0 讨论(0)
提交回复
热议问题