Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public static function createAuth($userId, \Overtrue\Socialite\User $user) |
||
23 | { |
||
24 | $type = strtolower($user->getProviderName()); |
||
25 | if (!isset(UserAuth::AUTH_TYPE_NAME[$type])) { |
||
26 | throw new \InvalidArgumentException('三方授权类型未注册'); |
||
27 | } |
||
28 | $data = []; |
||
29 | $data['type'] = UserAuth::AUTH_TYPE_NAME[$type]; |
||
30 | |||
31 | $data['user_id'] = $userId; |
||
32 | $data['openid'] = $user->getId(); |
||
33 | $data['avatar'] = (string) $user->getAvatar(); |
||
34 | $data['username'] = (string) $user->getName(); |
||
35 | $data['nick_name'] = (string) $user->getNickname(); |
||
36 | $data['email'] = (string) $user->getEmail(); |
||
37 | |||
38 | return UserAuth::query()->create($data); |
||
39 | } |
||
41 |