oauth login check user is normal

This commit is contained in:
xiaomlove
2025-05-06 20:25:57 +07:00
parent 32ff10923c
commit eb830ec869
3 changed files with 7 additions and 7 deletions
+4
View File
@@ -100,7 +100,11 @@ class OauthController extends Controller
->first(); ->first();
if ($socialAccount) { if ($socialAccount) {
//already bind, login directly //already bind, login directly
/**
* @var User $authUser
*/
$authUser = $socialAccount->user; $authUser = $socialAccount->user;
$authUser->checkIsNormal();
logincookie($authUser->id, $authUser->auth_key); logincookie($authUser->id, $authUser->auth_key);
return redirect($homeUrl); return redirect($homeUrl);
} }
+2 -1
View File
@@ -1,6 +1,7 @@
<?php <?php
namespace App\Repositories; namespace App\Repositories;
use App\Enums\ModelEventEnum;
use App\Exceptions\InsufficientPermissionException; use App\Exceptions\InsufficientPermissionException;
use App\Exceptions\NexusException; use App\Exceptions\NexusException;
use App\Http\Resources\ExamUserResource; use App\Http\Resources\ExamUserResource;
@@ -697,7 +698,7 @@ class UserRepository extends BaseRepository
NexusDB::statement(sprintf('DELETE FROM snatched WHERE userid IN (%s) and not exists (select 1 from torrents where id = snatched.torrentid)', $uidStr)); NexusDB::statement(sprintf('DELETE FROM snatched WHERE userid IN (%s) and not exists (select 1 from torrents where id = snatched.torrentid)', $uidStr));
if (is_int($id)) { if (is_int($id)) {
do_action("user_delete", $id); do_action("user_delete", $id);
fire_event("user_destroyed", $users->first()); fire_event(ModelEventEnum::USER_DELETED, $users->first());
} }
return true; return true;
} }
+1 -6
View File
@@ -1422,12 +1422,7 @@ function get_user_from_cookie(array $cookie, $isArray = true): array|\App\Models
do_log("$log, user not exists"); do_log("$log, user not exists");
return null; return null;
} }
try { $row->checkIsNormal();
$row->checkIsNormal();
} catch (\Exception $e) {
do_log("$log, " . $e->getMessage());
return null;
}
$authKey = $row->auth_key; $authKey = $row->auth_key;
} }
$expectedSignature = hash_hmac('sha256', $tokenJson, $authKey); $expectedSignature = hash_hmac('sha256', $tokenJson, $authKey);