Created
April 19, 2017 21:30
-
-
Save calebporzio/a7b3fc29807226e8d1d665c49a560816 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Until SessionGuard Macros get pulled into Laravel core from a PR: | |
// Remove this when Laravel 5.4.18 is released. | |
$this->app->config->set('auth.guards.hack', [ | |
'driver' => 'modified-session', | |
'provider' => 'users', | |
]); | |
Auth::extend('modified-session', function ($app, $name, $config) { | |
// The following is taken from AuthManager@createSessionDriver | |
$provider = Auth::createUserProvider($config['provider']); | |
$guard = new class ($name, $provider, $app['session.store']) extends SessionGuard { | |
// This allows Auth::macro(...) | |
use Macroable; | |
}; | |
if (method_exists($guard, 'setCookieJar')) { | |
$guard->setCookieJar($app['cookie']); | |
} | |
if (method_exists($guard, 'setDispatcher')) { | |
$guard->setDispatcher($app['events']); | |
} | |
if (method_exists($guard, 'setRequest')) { | |
$guard->setRequest($app->refresh('request', $guard, 'setRequest')); | |
} | |
return $guard; | |
}); | |
Auth::shouldUse('hack'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment