2
2
3
3
namespace Laravel \WorkOS \Http \Requests ;
4
4
5
- use App \Models \User as AppUser ;
6
5
use Illuminate \Auth \Events \Registered ;
6
+ use Illuminate \Contracts \Auth \Authenticatable ;
7
7
use Illuminate \Foundation \Http \FormRequest ;
8
8
use Illuminate \Support \Facades \Auth ;
9
+ use Illuminate \Support \Facades \Config ;
9
10
use Illuminate \Support \Facades \URL ;
10
11
use Inertia \Inertia ;
11
12
use Laravel \WorkOS \User ;
@@ -72,19 +73,19 @@ public function authenticate(?callable $findUsing = null, ?callable $createUsing
72
73
/**
73
74
* Find the user with the given WorkOS ID.
74
75
*/
75
- protected function findUsing (User $ user ): ?AppUser
76
+ protected function findUsing (User $ user ): ?Authenticatable
76
77
{
77
- /** @phpstan-ignore class.notFound */
78
- return AppUser ::where ('workos_id ' , $ user ->id )->first ();
78
+ $ userModelClass = Config:: get ( ' auth.providers.users.model ' );
79
+ return $ userModelClass ::where ('workos_id ' , $ user ->id )->first ();
79
80
}
80
81
81
82
/**
82
83
* Create a user from the given WorkOS user.
83
84
*/
84
- protected function createUsing (User $ user ): AppUser
85
+ protected function createUsing (User $ user ): Authenticatable
85
86
{
86
- /** @phpstan-ignore class.notFound */
87
- return AppUser ::create ([
87
+ $ userModelClass = Config:: get ( ' auth.providers.users.model ' );
88
+ return $ userModelClass ::create ([
88
89
'name ' => $ user ->firstName .' ' .$ user ->lastName ,
89
90
'email ' => $ user ->email ,
90
91
'email_verified_at ' => now (),
@@ -96,7 +97,7 @@ protected function createUsing(User $user): AppUser
96
97
/**
97
98
* Update a user from the given WorkOS user.
98
99
*/
99
- protected function updateUsing (AppUser $ user , User $ userFromWorkOS ): AppUser
100
+ protected function updateUsing (Authenticatable $ user , User $ userFromWorkOS ): Authenticatable
100
101
{
101
102
return tap ($ user )->update ([
102
103
// 'name' => $userFromWorkOS->firstName.' '.$userFromWorkOS->lastName,
0 commit comments