Laravel Fortify: Authenticate Using Return Closure / Returning Custom Closure

Viewed 183

I am using Fortify to validate a user via a API, which returns a json array of user data.

{
    "userid": "1",
    "twoFactorEnabled": "false"
}

Here is what I am doing within the authenticate using method within Fortify Boot.

Fortify::authenticateUsing(function (Request $request) {
    if($api->validate($request->username, $request->passwprd)) {
        return $api->find($request->username);
    }
});

I am doing the above to validate whether or not the username, and password is correct.

Then I am returning the above JSON array if that user is validated from the array.

However, when I do this I receive the following Error from the frontend.

Illuminate\Auth\SessionGuard::login(): Argument #1 ($user) must be of type Illuminate\Contracts\Auth\Authenticatable, array given, called in /home/-/my..io/vendor/laravel/fortify/src/Actions/AttemptToAuthenticate.php on line 80

I have got no Database access at all, this must all be done via the data response from API.

0 Answers
Related