Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PHP
socialite
Commits
09d2add9
Commit
09d2add9
authored
5 years ago
by
康帅杰
Browse files
Options
Download
Email Patches
Plain Diff
task#1210 写入订阅获取用户信息的时候,判断用户唯一错误
parent
6f391f1b
master
v2
1.0.8
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Listeners/SocialiteLogUserListener.php
+1
-4
src/Listeners/SocialiteLogUserListener.php
src/Models/AbstractModel.php
+7
-0
src/Models/AbstractModel.php
src/Models/Apple.php
+4
-4
src/Models/Apple.php
src/Models/Wechat.php
+5
-4
src/Models/Wechat.php
with
17 additions
and
12 deletions
+17
-12
src/Listeners/SocialiteLogUserListener.php
View file @
09d2add9
...
...
@@ -21,15 +21,12 @@ class SocialiteLogUserListener{
public
function
handle
(
SocialiteLogUser
$event
){
$class
=
'Yjtec\\Socialite\\Models\\'
.
ucfirst
(
$event
->
driver
);
$clientId
=
$event
->
clientId
;
$formatUser
=
(
new
$class
(
$event
->
user
))
->
toArray
();
if
(
!
(
new
$class
)
->
where
(
$formatUser
)
->
get
()
->
isNotEmpty
()){
if
(
!
(
new
$class
)
->
uniqUser
(
$event
->
user
)){
$user
=
(
new
$class
)
->
create
(
array_merge
(
$event
->
user
,
[
'client_id'
=>
$clientId
]
));
$social
=
(
new
Socialite
)
->
create
([
'socialitetable_id'
=>
$user
->
id
,
'socialitetable_type'
=>
$class
...
...
This diff is collapsed.
Click to expand it.
src/Models/AbstractModel.php
0 → 100644
View file @
09d2add9
<?php
namespace
Yjtec\Socialite\Models
;
use
Illuminate\Database\Eloquent\Model
;
abstract
class
AbstractModel
extends
Model
{
abstract
public
function
uniqUser
(
array
$user
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Models/Apple.php
View file @
09d2add9
<?php
namespace
Yjtec\Socialite\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
Apple
extends
Model
class
Apple
extends
AbstractModel
{
protected
$table
=
'socialite_apple'
;
protected
$fillable
=
[
'sub'
,
'client_id'
];
public
function
uniqUser
(
array
$user
){
return
$this
->
where
(
'sub'
,
$user
[
'sub'
])
->
first
();
}
}
This diff is collapsed.
Click to expand it.
src/Models/Wechat.php
View file @
09d2add9
<?php
namespace
Yjtec\Socialite\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
Wechat
extends
Model
class
Wechat
extends
AbstractModel
{
protected
$table
=
'socialite_wechat'
;
protected
$fillable
=
[
'client_id'
,
'openid'
,
'unionid'
,
'nickname'
,
'sex'
,
'city'
,
'province'
,
'country'
,
'headimgurl'
];
public
function
uniqUser
(
array
$user
){
return
$this
->
where
(
'openid'
,
$user
[
'openid'
])
->
first
();
}
public
function
setNicknameAttribute
(
$value
){
$this
->
attributes
[
'nickname'
]
=
userTextEncode
(
$value
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help