This commit is contained in:
扶桑花间 2025-08-27 20:20:24 +08:00
parent 18d0d9fef9
commit ab9af25691
5 changed files with 19 additions and 8 deletions

View File

@ -3,6 +3,9 @@
namespace app\controller\admin\auth;
use app\BaseController;
use app\entity\SysUser;
use app\enum\UserTypeEnum;
use app\http\HttpAuth;
use app\service\admin\LoginService;
use think\exception\ValidateException;
@ -18,6 +21,7 @@ class LoginController extends BaseController
'text' => $captchaData['data']['text'] ?? '',
]);
}
public function index()
{
$username = $this->request->post('username', '');
@ -28,6 +32,10 @@ class LoginController extends BaseController
$loginService = new LoginService();
try {
$result = $loginService->login($this->request, $this->request->getClient(), $username, $password, $code, $remember);
// 绑定Auth
$this->request->setAuth(new HttpAuth($result['user']['userId'], UserTypeEnum::USER));
security_log_record([SysUser::class, "userLogin"], "{$username}登录了系统", '');
} catch (ValidateException $e) {
return $this->writeError($e->getError());
}

View File

@ -40,7 +40,6 @@ class ContextMiddleware extends middleware
$log = (array)$this->app->config->get('admin.httpLog');
$logOpen = $log['open'] ?? false;
$logOpen = false;
if (!$logOpen || in_array($request->method() . '@' . $request->pathinfo(),$this->noHttpLog)) {
return;
}

View File

@ -81,6 +81,7 @@ class LoginService
'ip' => $request->ip(),
'comments' => $comments,
'login_type' => $loginType->value,
'context_id' => $request->contextId,
]);
}

View File

@ -9,7 +9,7 @@ return [
'open_start_time' => 0,
'open_end_time' => 0,
'recordRules' => [
'include_methods' => ['GET', 'POST', 'PUT', 'DELETE'],
'include_methods' => ['POST', 'PUT', 'DELETE'],
'include_responses' => [Json::class],
'include_codes' => [],
'exclude_codes' => [],

View File

@ -52,9 +52,7 @@
Columns
} from 'ele-admin-plus/es/ele-pro-table/types';
import LoginRecordSearch from './components/login-record-search.vue';
import {
pageLoginRecords,
} from '@/api/system/login-record';
import { pageLoginRecords } from '@/api/system/login-record';
import type { LoginRecordParam } from '@/api/system/login-record/model';
defineOptions({ name: 'SystemLoginRecord' });
@ -76,6 +74,11 @@
width: 50,
align: 'center'
},
{
prop: 'contextId',
label: 'ContextId',
width: 280
},
{
prop: 'username',
label: '账号',