namespace App\Providers; use App\Models\ApiUser; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\UserProvider; use Illuminate\Contracts\Encryption\EncryptException; use Illuminate\Http\Client\Response; use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Http; use Tymon\JWTAuth\Facades\JWTAuth; class ApiUserProvider implements UserProvider { public function retrieveById($identifier) { //identifier value is 0. die('retrieveById'); } public function retrieveByToken($identifier, $token) { die('retrieveByToken'); } public function updateRememberToken(Authenticatable $user, $token) { die('updateRememberToken'); } public function retrieveByCredentials(array $credentials) { if (! array_key_exists('login', $credentials)) {return null;} if (! array_key_exists('password', $credentials)) {return null;} $response = $this->loginWithApi($credentials['login'], $credentials['password']); // if (!$response->ok()) {return null;} $userData = $response->json(); $payload['name'] = $userData['data']['player']['name']; try { $identifier = \json_encode($payload, \JSON_THROW_ON_ERROR); $payload['id'] = Crypt::encryptString($identifier); } catch (\JsonException $exception) { return null; } catch (EncryptException $exception) { return null; } return new ApiUser($payload); } public function validateCredentials(Authenticatable $user, array $credentials) { return true; } private function loginWithApi(string $login, string $password): Response { return } }
* @return void */ public function register($provider) { if (! $provider instanceof ServiceProvider) { $provider = new $provider($this); } if (array_key_exists($providerName = get_class($provider), $this->loadedProviders)) { return; }*/// $app->register(App\Providers\AppServiceProvider::class); $app->register(App\Providers\AuthServiceProvider::class);// $app->register(App\Providers\EventServiceProvider::class);$app->register(App\Providers\ApiUserProvider::class);/*|--------------------------------------------------------------------------| Load The Application Routes|--------------------------------------------------------------------------| of the application / container and bootstraps the application so it| is ready to receive HTTP / Console requests from the environment.|*/$app = require __DIR__.'/../bootstrap/app.php';/*|--------------------------------------------------------------------------| Run The Application|--------------------------------------------------------------------------|
Error
|
|---|
Error:
Class 'App\Providers\ApiUserProvider' not found
at /home/reactivecrmkools/public_html/api/v1_cestino/vendor/laravel/lumen-framework/src/Application.php:223
at Laravel\Lumen\Application->register('App\\Providers\\ApiUserProvider')
(/home/reactivecrmkools/public_html/api/v1_cestino/bootstrap/app.php:97)
at require('/home/reactivecrmkools/public_html/api/v1_cestino/bootstrap/app.php')
(/home/reactivecrmkools/public_html/api/v1_cestino/public/index.php:14)
|