From eb830ec86945c6db087c6304c6595c3b2b931df2 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Tue, 6 May 2025 20:25:57 +0700 Subject: [PATCH] oauth login check user is normal --- app/Http/Controllers/OauthController.php | 4 ++++ app/Repositories/UserRepository.php | 3 ++- include/globalfunctions.php | 7 +------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/OauthController.php b/app/Http/Controllers/OauthController.php index ce373f0e..4b82e8d7 100644 --- a/app/Http/Controllers/OauthController.php +++ b/app/Http/Controllers/OauthController.php @@ -100,7 +100,11 @@ class OauthController extends Controller ->first(); if ($socialAccount) { //already bind, login directly + /** + * @var User $authUser + */ $authUser = $socialAccount->user; + $authUser->checkIsNormal(); logincookie($authUser->id, $authUser->auth_key); return redirect($homeUrl); } diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 98a6df22..74860cb4 100644 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -1,6 +1,7 @@ first()); + fire_event(ModelEventEnum::USER_DELETED, $users->first()); } return true; } diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 11ea5b97..135f6194 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -1422,12 +1422,7 @@ function get_user_from_cookie(array $cookie, $isArray = true): array|\App\Models do_log("$log, user not exists"); return null; } - try { - $row->checkIsNormal(); - } catch (\Exception $e) { - do_log("$log, " . $e->getMessage()); - return null; - } + $row->checkIsNormal(); $authKey = $row->auth_key; } $expectedSignature = hash_hmac('sha256', $tokenJson, $authKey);