0

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.

kushalbhaktajoshi
  • 4,640
  • 3
  • 22
  • 37
  • `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 Aug 23 '17 at 21:50
  • actually i need to replace the model with soap service . . so i don't have any idea on how to get over it. – kushalbhaktajoshi Aug 23 '17 at 21:58
  • could you shared your code? also, have you crosschecked that answer with the proper [documentation regarding laravel custom provider](https://laravel.com/docs/5.4/authentication#adding-custom-user-providers)? as it is stated that you will need to have to really implement the user class with `Authenticatable`.. – Bagus Tesa Aug 24 '17 at 01:00
  • 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 Aug 26 '17 at 00:42
  • 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 Aug 26 '17 at 21:10

1 Answers1

0

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]);
  • this works fine only when you use model. But in my situation, i need to make the code work only when Soap Service replaces the model. Do you have any solution for this ? – kushalbhaktajoshi Aug 26 '17 at 00:45