Projekt

Obecné

Profil

Stáhnout (1.01 KB) Statistiky
| Větev: | Revize:
1
<?php
2

    
3
namespace App\Providers;
4

    
5
use App\User;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Gate;
8
use Illuminate\Support\ServiceProvider;
9

    
10
class AuthServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Register any application services.
14
     *
15
     * @return void
16
     */
17
    public function register()
18
    {
19
        //
20
    }
21

    
22
    /**
23
     * Boot the authentication services for the application.
24
     *
25
     * @return void
26
     */
27
    public function boot()
28
    {
29
        // Here you may define how you wish users to be authenticated for your Lumen
30
        // application. The callback which receives the incoming request instance
31
        // should return either a User instance or null. You're free to obtain
32
        // the User instance via an API token or any other method necessary.
33

    
34
        Auth::viaRequest('api', function ($request) {
35
            if ($request->input('api_token')) {
36
                return User::where('api_token', $request->input('api_token'))->first();
37
            }
38
        });
39
    }
40
}
(2-2/3)