diff options
author | Camil Staps | 2016-09-04 23:30:15 +0200 |
---|---|---|
committer | Camil Staps | 2016-09-04 23:30:15 +0200 |
commit | c61b156f1bd93ec4aadd8adc78523b42b0232918 (patch) | |
tree | cd9bcb6f889dcf554818246957bed54eb14c9fbe /app/Providers/AuthServiceProvider.php | |
parent | Use blade templates (diff) |
User creation and authentication
Diffstat (limited to 'app/Providers/AuthServiceProvider.php')
-rw-r--r-- | app/Providers/AuthServiceProvider.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php new file mode 100644 index 0000000..7cf4b27 --- /dev/null +++ b/app/Providers/AuthServiceProvider.php @@ -0,0 +1,39 @@ +<?php + +namespace App\Providers; + +use App\User; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Gate; +use Illuminate\Support\ServiceProvider; + +class AuthServiceProvider extends ServiceProvider +{ + /** + * Register any application services. + * + * @return void + */ + public function register() + { + // + } + + /** + * Boot the authentication services for the application. + * + * @return void + */ + 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. + Auth::viaRequest('api', function ($request) { + if ($request->input('api_token')) { + return User::where('api_token', $request->input('api_token'))->first(); + } + }); + } +} |