summaryrefslogtreecommitdiff
path: root/app/Providers/AuthServiceProvider.php
diff options
context:
space:
mode:
authorCamil Staps2016-01-22 12:01:33 +0100
committerCamil Staps2016-01-22 12:01:33 +0100
commit3a74377e861c1a401f1dffbd595f547e04eb72c8 (patch)
tree505649f58784ed0e318cb46f28777173bcdc6b90 /app/Providers/AuthServiceProvider.php
Initial commitlumen-app
Diffstat (limited to 'app/Providers/AuthServiceProvider.php')
-rw-r--r--app/Providers/AuthServiceProvider.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
new file mode 100644
index 0000000..3565688
--- /dev/null
+++ b/app/Providers/AuthServiceProvider.php
@@ -0,0 +1,40 @@
+<?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();
+ }
+ });
+ }
+}