Last active
February 16, 2016 14:29
-
-
Save josh7weaver/9de6162b442bdc3803b0 to your computer and use it in GitHub Desktop.
Custom Auth Driver (http://laravel.io/forum/11-04-2014-laravel-5-how-do-i-create-a-custom-auth-in-laravel-5)
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
'providers' => [ | |
/* | |
* Laravel Framework Service Providers... | |
*/ | |
'Illuminate\Foundation\Providers\ArtisanServiceProvider', | |
'Illuminate\Auth\AuthServiceProvider', | |
'Illuminate\Bus\BusServiceProvider', | |
'Illuminate\Cache\CacheServiceProvider', | |
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', | |
'Illuminate\Routing\ControllerServiceProvider', | |
'Illuminate\Cookie\CookieServiceProvider', | |
'Illuminate\Database\DatabaseServiceProvider', | |
'Illuminate\Encryption\EncryptionServiceProvider', | |
'Illuminate\Filesystem\FilesystemServiceProvider', | |
'Illuminate\Foundation\Providers\FoundationServiceProvider', | |
'Illuminate\Hashing\HashServiceProvider', | |
'Illuminate\Mail\MailServiceProvider', | |
'Illuminate\Pagination\PaginationServiceProvider', | |
'Illuminate\Pipeline\PipelineServiceProvider', | |
'Illuminate\Queue\QueueServiceProvider', | |
'Illuminate\Redis\RedisServiceProvider', | |
'Illuminate\Auth\Passwords\PasswordResetServiceProvider', | |
'Illuminate\Session\SessionServiceProvider', | |
'Illuminate\Translation\TranslationServiceProvider', | |
'Illuminate\Validation\ValidationServiceProvider', | |
'Illuminate\View\ViewServiceProvider', | |
/* | |
* Laravel extensions | |
*/ | |
'Illuminate\Html\HtmlServiceProvider', | |
/* | |
* Application Service Providers... | |
*/ | |
'tbb\Providers\AppServiceProvider', | |
'tbb\Providers\BusServiceProvider', | |
'tbb\Providers\ConfigServiceProvider', | |
'tbb\Providers\EventServiceProvider', | |
'tbb\Providers\RouteServiceProvider', | |
'tbb\Providers\TokenAuthServiceProvider', | |
], |
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
return [ | |
//... | |
'driver' => 'custom', | |
//... | |
] |
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 namespace tbb\Auth; | |
use Illuminate\Contracts\Auth\UserProvider; | |
use Illuminate\Contracts\Hashing\Hasher as HasherContract; | |
use Illuminate\Contracts\Auth\Authenticatable as UserContract; | |
class CustomUserProvider implements UserProvider { | |
protected $model; | |
public function __construct(UserContract $model) | |
{ | |
$this->model = $model; | |
} | |
public function retrieveById($identifier) | |
{ | |
} | |
public function retrieveByToken($identifier, $token) | |
{ | |
} | |
public function updateRememberToken(UserContract $user, $token) | |
{ | |
} | |
public function retrieveByCredentials(array $credentials) | |
{ | |
} | |
public function validateCredentials(UserContract $user, array $credentials) | |
{ | |
} | |
} |
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
in Manager.php line 92 | |
at Manager->createDriver('custom') in AuthManager.php line 15 | |
at AuthManager->createDriver('custom') in Manager.php line 62 | |
at Manager->driver() in AuthServiceProvider.php line 40 | |
at AuthServiceProvider->Illuminate\Auth\{closure}(object(Application), array()) in Container.php line 773 | |
at Container->build(object(Closure), array()) in Container.php line 656 | |
at Container->make('auth.driver', array()) in Application.php line 613 | |
at Application->make('Illuminate\Contracts\Auth\Guard') in Container.php line 597 | |
at Container->addDependencyForCallParameter(object(ReflectionParameter), array(), array()) in Container.php line 552 | |
at Container->getMethodDependencies(array(object(AppServiceProvider), 'boot'), array()) in Container.php line 521 | |
at Container->call(array(object(AppServiceProvider), 'boot')) in Application.php line 672 | |
at Application->bootProvider(object(AppServiceProvider)) in Application.php line 654 | |
at Application->Illuminate\Foundation\{closure}(object(AppServiceProvider), '14') | |
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(ControllerServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FormRequestServiceProvider), object(FoundationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ValidationServiceProvider), object(ViewServiceProvider), object(AppServiceProvider), object(BusServiceProvider), object(ConfigServiceProvider), object(EventServiceProvider), object(RouteServiceProvider), object(TokenAuthServiceProvider)), object(Closure)) in Application.php line 655 | |
at Application->boot() in BootProviders.php line 15 | |
at BootProviders->bootstrap(object(Application)) in Application.php line 167 | |
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 163 | |
at Kernel->bootstrap() in Kernel.php line 106 | |
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84 | |
at Kernel->handle(object(Request)) in index.php line 53 |
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 namespace tbb\Providers; | |
use Illuminate\Support\ServiceProvider; | |
use tbb\Services\CustomUserProvider; | |
class TokenAuthServiceProvider extends ServiceProvider { | |
/** | |
* Bootstrap the application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
$this->app['auth']->extend('token',function() | |
{ | |
$model = $this->app['config']['auth.model']; | |
return new CustomUserProvider($this->app['hash'], $model); | |
}); | |
} | |
public function register() | |
{ | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment