-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseOAuthUserHandler.php
More file actions
33 lines (28 loc) · 838 Bytes
/
BaseOAuthUserHandler.php
File metadata and controls
33 lines (28 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
namespace Raiolanetworks\OAuth\Handlers;
use Illuminate\Database\Eloquent\Model;
use League\OAuth2\Client\Token\AccessTokenInterface;
use Raiolanetworks\OAuth\Contracts\OAuthUserHandlerInterface;
use Raiolanetworks\OAuth\Models\OAuth;
class BaseOAuthUserHandler implements OAuthUserHandlerInterface
{
/**
* Handle user logged with OAuth provider.
*
* @param array<mixed> $userData
*/
public function handleUser(array $userData, AccessTokenInterface $accessToken): Model
{
/** @var Model $model */
$model = config('oauth.user_model_name');
return (new $model())::updateOrCreate(
[
'email' => $userData['email'],
],
[
'name' => $userData['name'],
]
);
}
}