up.
This commit is contained in:
parent
18d0d9fef9
commit
ab9af25691
@ -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;
|
||||
|
||||
@ -14,10 +17,11 @@ class LoginController extends BaseController
|
||||
$captchaData = json_decode($captcha, true);
|
||||
|
||||
return $this->writeSuccess('登录成功', [
|
||||
'base64'=> $captchaData['data']['base64'] ?? '',
|
||||
'text'=> $captchaData['data']['text'] ?? '',
|
||||
'base64' => $captchaData['data']['base64'] ?? '',
|
||||
'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());
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -81,6 +81,7 @@ class LoginService
|
||||
'ip' => $request->ip(),
|
||||
'comments' => $comments,
|
||||
'login_type' => $loginType->value,
|
||||
'context_id' => $request->contextId,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -95,7 +96,7 @@ class LoginService
|
||||
$headers = new stdClass();
|
||||
$data = JWT::decode($token, new Key($jwtKey, 'HS256'), $headers);
|
||||
} catch (UnexpectedValueException $e) {
|
||||
if($e->getMessage() == "Expired token") {
|
||||
if ($e->getMessage() == "Expired token") {
|
||||
throw new ValidateException('凭证过期');
|
||||
}
|
||||
throw new ValidateException('校验失败' . $e->getMessage());
|
||||
|
||||
@ -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' => [],
|
||||
|
||||
@ -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: '账号',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user