'Login with laravel/fortify to external api

I have implemented fortify to perform the startup, but I don't have a database, because I have an api with an endpoint to verify a registered user.

So, I thought about adding to the user model the user data returned by the api and then just return the user already instantiated, but it doesn't work, it seems to me that fortify verifies that the user exists but since there is no database it returns null and doesn't create the session.

Fortify::authenticateUsing(function (Request $request) {
            $api = new Api();
            $response = $api->verifyUser(['user'=>'[email protected]','password'=>'123']);
            $user = new User();
            $user->username = $response->username;
            $user->email = $response->email;
            $user->name  = $response->name;
            
            return $user;
            
        });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source