diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 2baffc3..5b79b49 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -3,6 +3,3 @@ parameters: - src level: 0 - - ignoreErrors: - - '#has invalid (return type|type) App\\Models\\User#' diff --git a/src/Http/Requests/AuthKitAuthenticationRequest.php b/src/Http/Requests/AuthKitAuthenticationRequest.php index 2c932cb..8eb5947 100644 --- a/src/Http/Requests/AuthKitAuthenticationRequest.php +++ b/src/Http/Requests/AuthKitAuthenticationRequest.php @@ -2,10 +2,11 @@ namespace Laravel\WorkOS\Http\Requests; -use App\Models\User as AppUser; use Illuminate\Auth\Events\Registered; +use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\URL; use Inertia\Inertia; use Laravel\WorkOS\User; @@ -72,19 +73,21 @@ public function authenticate(?callable $findUsing = null, ?callable $createUsing /** * Find the user with the given WorkOS ID. */ - protected function findUsing(User $user): ?AppUser + protected function findUsing(User $user): ?Authenticatable { - /** @phpstan-ignore class.notFound */ - return AppUser::where('workos_id', $user->id)->first(); + $userModelClass = Config::get('auth.providers.users.model'); + + return $userModelClass::where('workos_id', $user->id)->first(); } /** * Create a user from the given WorkOS user. */ - protected function createUsing(User $user): AppUser + protected function createUsing(User $user): Authenticatable { - /** @phpstan-ignore class.notFound */ - return AppUser::create([ + $userModelClass = Config::get('auth.providers.users.model'); + + return $userModelClass::create([ 'name' => $user->firstName.' '.$user->lastName, 'email' => $user->email, 'email_verified_at' => now(), @@ -96,7 +99,7 @@ protected function createUsing(User $user): AppUser /** * Update a user from the given WorkOS user. */ - protected function updateUsing(AppUser $user, User $userFromWorkOS): AppUser + protected function updateUsing(Authenticatable $user, User $userFromWorkOS): Authenticatable { return tap($user)->update([ // 'name' => $userFromWorkOS->firstName.' '.$userFromWorkOS->lastName,