mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 17:07:49 +08:00
fix : common request
This commit is contained in:
@@ -50,7 +50,7 @@ class AdminLoginLogAspect extends AbstractAspect
|
||||
*/
|
||||
public function __construct(
|
||||
protected readonly Logger $logger,
|
||||
protected readonly RequestInterface $request,
|
||||
protected RequestInterface $request,
|
||||
protected readonly AdminUserRepository $adminUserRepository,
|
||||
protected readonly AdminUserLoginLog $adminUserLoginLogModel,
|
||||
) {}
|
||||
@@ -61,7 +61,7 @@ class AdminLoginLogAspect extends AbstractAspect
|
||||
* @throws Exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function process(ProceedingJoinPoint $proceedingJoinPoint)
|
||||
public function process(ProceedingJoinPoint $proceedingJoinPoint): mixed
|
||||
{
|
||||
// 写日志
|
||||
|
||||
@@ -87,23 +87,24 @@ class AdminLoginLogAspect extends AbstractAspect
|
||||
*/
|
||||
private function writeLoginLog(): void
|
||||
{
|
||||
Coroutine::create(function () {
|
||||
$userInfo = $this->adminUserRepository->findByUserName($this->request->input('username'));
|
||||
$context = [
|
||||
'username' => $this->request->input('username',''),
|
||||
'password' => $this->request->input('password',''),
|
||||
'user_info' => $userInfo?->toArray() ?? [],
|
||||
'ip' => $this->getClientIp(),
|
||||
'os' => $this->getClientOs(),
|
||||
'browser' => $this->request->header('User-Agent') ?: 'unknown',
|
||||
];
|
||||
$userInfo = $this->adminUserRepository->findByUserName($this->request->input('username'));
|
||||
|
||||
$context = [
|
||||
'username' => $this->request->input('username',''),
|
||||
'password' => $this->request->input('password',''),
|
||||
'user_info' => $userInfo?->toArray() ?? [],
|
||||
'ip' => $this->getClientIp(),
|
||||
'os' => $this->getClientOs(),
|
||||
'browser' => $this->request->header('User-Agent') ?: 'unknown',
|
||||
];
|
||||
|
||||
Coroutine::create(function () use ($userInfo, $context) {
|
||||
$this->logger->request()->info('admin_login_log', $context);
|
||||
|
||||
$this->adminUserLoginLogModel->save([
|
||||
$this->adminUserLoginLogModel->create([
|
||||
'admin_user_id' => $userInfo?->id ?? 0,
|
||||
'username' => $userInfo?->username ?? '',
|
||||
'ip' => $context['ip'],
|
||||
'ip' => current($context['ip']) ?: '0.0.0.0',
|
||||
'os' => $context['os'],
|
||||
'browser' => $context['browser'] ?? '',
|
||||
'status' => $this->loginSuccess ? 1 : 2,
|
||||
|
||||
Reference in New Issue
Block a user