Projeto

Geral

Perfil

Estatísticas
| Branch: | Revisão:

expressolivretools / app / Providers / AuthServiceProvider.php @ 3e379cec

Histórico | Ver | Anotar | Baixar (1023 Bytes)

1
<?php
2

    
3
namespace App\Providers;
4

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

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

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

    
33
        $this->app['auth']->viaRequest('api', function ($request) {
34
            if ($request->input('api_token')) {
35
                return User::where('api_token', $request->input('api_token'))->first();
36
            }
37
        });
38
    }
39
}