Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2022-03-29 18:14:59 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
adde58f41dab35c88495c27500e3182912ea5f4f
adde58f4
1 parent
ac707625
1.测试OAuth
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
2 deletions
app/Http/Controllers/V1/AuthController.php
app/Http/Controllers/V1/AuthController.php
View file @
adde58f
...
...
@@ -83,9 +83,37 @@ class AuthController extends Controller
if
(
!
$code
)
return
Response
::
fail
(
'code miss'
);
$user
=
Socialite
::
driver
(
$service
)
->
stateless
()
->
user
();
$socialUser
=
Socialite
::
driver
(
$service
)
->
stateless
()
->
user
();
$user
=
User
::
query
()
->
where
(
'provider'
,
$service
)
->
where
(
'provider_id'
,
$socialUser
->
id
)
->
first
();
// if ($user == null){
//
// // 如果该用户不存在则将其保存到 users 表
// $newUser = new User();
//
// $newUser->name = $socialUser->getName();
// $newUser->email = $socialUser->getEmail() == '' ? '' : $socialUser->getEmail();
// $newUser->avatar = $socialUser->getAvatar();
// $newUser->password = '';
// $newUser->provider = $account;
// $newUser->provider_id = $socialUser->getId();
//
// $newUser->save();
// $user = $newUser;
// }
//
//
// Auth::login();
return
Response
::
success
(
$socialUser
);
return
Response
::
success
(
$user
);
// //另一种写法
// $user = User::query()->firstOrCreate([
...
...
Please
register
or
login
to post a comment