12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- /*
- * This file is part of the Jiannei/lumen-api-starter.
- *
- * (c) Jiannei <longjian.huang@foxmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace App\Providers;
- use App\Repositories\Enums\PermissionEnum;
- use Illuminate\Support\Facades\Gate;
- use Illuminate\Support\ServiceProvider;
- class AuthServiceProvider extends ServiceProvider
- {
- /**
- * Register any application services.
- */
- public function register()
- {
- }
- /**
- * Boot the authentication services for the application.
- */
- public function boot()
- {
- // Here you may define how you wish users to be authenticated for your Lumen
- // application. The callback which receives the incoming request instance
- // should return either a User instance or null. You're free to obtain
- // the User instance via an API token or any other method necessary.
- /*$this->app['auth']->viaRequest('api', function ($request) {
- if ($request->input('api_token')) {
- return User::where('api_token', $request->input('api_token'))->first();
- }
- });*/
- Gate::before(PermissionEnum::gateBeforeCallback());
- $this->app['auth']->provider('custom', function ($app, array $config) {
- return new EloquentUserProvider($app['hash'], $config['model']);
- });
- }
- }
|