Files
api-extranetwork/app/Providers/AuthServiceProvider.php
ExtraNetwork e5c4b6aa13 first commit
2026-05-12 17:04:54 +03:00

40 lines
1.0 KiB
PHP

<?php
namespace App\Providers;
use App\Models\Users;
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 Users instance or null. You're free to obtain
// the Users instance via an API token or any other method necessary.
$this->app['auth']->viaRequest('api', function ($request) {
if ($request->input('api_token')) {
return Users::where('api_token', $request->input('api_token'))->first();
}
});
}
}