Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ parameters:
- src

level: 0

ignoreErrors:
- '#has invalid (return type|type) App\\Models\\User#'
19 changes: 11 additions & 8 deletions src/Http/Requests/AuthKitAuthenticationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
Expand Down