Laravel 5.4 custom authentication without database

685 Views Asked by At

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

There are 1 best solutions below

1
On

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]);