0
votes

I have no database in my laravel application. I am using Soap service for data fetching in this application. I have followed instructions from the solution of this link from stackoverflow to replace the existing laravel's authentication with custom authentication. But when i reached method retrieveByCredentials(), I couldn't return the stdlib class object for user detail. Instead it returned following error.

(1/1) FatalThrowableError Type error: Argument 1 passed to App\Auth\SoapUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of stdClass given, called in C:\xampp\7.1.7\htdocs\gazebo_revamp\vendor\laravel\framework\src\Illuminate\Auth\SessionGuard.php on line 380

Please shed some light on this.

1
Illuminate\Contracts\Auth\Authenticatable hmm, should be clear enough, if you noticed, Laravel did not use stdlib class, but a class that implements the contract. Please take a look on sample project's User models.Bagus Tesa
actually i need to replace the model with soap service . . so i don't have any idea on how to get over it.kushalbhaktajoshi
could you shared your code? also, have you crosschecked that answer with the proper documentation regarding laravel custom provider? as it is stated that you will need to have to really implement the user class with Authenticatable..Bagus Tesa
Yes that sample code works when we use model. But, when we don't use model and make the code work with soap service, it fails to instantiate Authenticatable which is not possible from OOP.kushalbhaktajoshi
sorry, perhaps i am unclear. what do you mean intantiate Authenticatable? i suggest to drop the idea outputting stdclass, but a custom class - not a Model - that implements Authenticatable.Bagus Tesa

1 Answers

0
votes

If you are using a custom User auth provider then in the retrieveByCredentials() method instantiate a new User class and return it. Like so:

if ($api_auth === true )
        return new \App\User(['id' => 0]);