mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
fix oauth login
This commit is contained in:
@@ -89,10 +89,21 @@ class OauthController extends Controller
|
||||
$response = Http::withToken($tokenInfo['access_token'])->get($provider->user_info_endpoint_url);
|
||||
$userInfo = $response->json();
|
||||
do_log("userInfo: " . $response->body());
|
||||
$homeUrl = getSchemeAndHttpHost() . "/index.php";
|
||||
$providerUserId = data_get($userInfo, $provider->id_claim);
|
||||
if (empty($providerUserId)) {
|
||||
throw new NexusException(nexus_trans('oauth.get_provider_user_id_error', ['id_claim' => $provider->id_claim]));
|
||||
}
|
||||
$socialAccount = SocialAccount::query()
|
||||
->where('provider_id', $provider->id)
|
||||
->where('provider_user_id', $providerUserId)
|
||||
->first();
|
||||
if ($socialAccount) {
|
||||
//already bind, login directly
|
||||
$authUser = $socialAccount->user;
|
||||
logincookie($authUser->id, $authUser->auth_key);
|
||||
return redirect($homeUrl);
|
||||
}
|
||||
$providerEmail = data_get($userInfo, $provider->email_claim);
|
||||
if (empty($providerEmail)) {
|
||||
throw new NexusException(nexus_trans('oauth.get_provider_email_error', ['email_claim' => $provider->email_claim]));
|
||||
@@ -104,17 +115,7 @@ class OauthController extends Controller
|
||||
}
|
||||
$providerUsername = data_get($userInfo, $provider->username_claim);
|
||||
$providerLevel = data_get($userInfo, $provider->level_claim);
|
||||
$homeUrl = getSchemeAndHttpHost() . "/index.php";
|
||||
$socialAccount = SocialAccount::query()
|
||||
->where('provider_id', $provider->id)
|
||||
->where('provider_user_id', $providerUserId)
|
||||
->first();
|
||||
if ($socialAccount) {
|
||||
//already bind, login directly
|
||||
$authUser = $socialAccount->user;
|
||||
logincookie($authUser->id, $authUser->auth_key);
|
||||
return redirect($homeUrl);
|
||||
}
|
||||
|
||||
$minLevel = $provider->level_limit;
|
||||
if ($minLevel) {
|
||||
if (!$providerLevel) {
|
||||
|
||||
@@ -18,7 +18,6 @@ class NexusFormatter
|
||||
if (nexus()) {
|
||||
$id = nexus()->getRequestId();
|
||||
}
|
||||
$id .= " -> " . getLogFile();
|
||||
$format = "[%datetime%] [" . $id . "] %channel%.%level_name%: %message% %context% %extra%\n";
|
||||
return tap(new LineFormatter($format, 'Y-m-d H:i:s', true, true), function ($formatter) {
|
||||
$formatter->includeStacktraces();
|
||||
|
||||
@@ -17,7 +17,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'daily'),
|
||||
'default' => env('LOG_CHANNEL', 'single'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -37,7 +37,7 @@ return [
|
||||
'channels' => [
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => ['daily'],
|
||||
'channels' => ['single'],
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
|
||||
Reference in New Issue
Block a user