File tree Expand file tree Collapse file tree 9 files changed +30
-17
lines changed
Expand file tree Collapse file tree 9 files changed +30
-17
lines changed Original file line number Diff line number Diff line change 33from fastapi .security import OAuth2PasswordRequestForm
44from apps .system .schemas .system_schema import BaseUserDTO
55from common .core .deps import SessionDep , Trans
6+ from common .utils .crypto import sqlbot_decrypt
67from ..crud .user import authenticate
78from common .core .security import create_access_token
89from datetime import timedelta
1112router = APIRouter (tags = ["login" ], prefix = "/login" )
1213
1314@router .post ("/access-token" )
14- def local_login (
15+ async def local_login (
1516 session : SessionDep ,
1617 trans : Trans ,
1718 form_data : Annotated [OAuth2PasswordRequestForm , Depends ()]
1819) -> Token :
19- user : BaseUserDTO = authenticate (session = session , account = form_data .username , password = form_data .password )
20+ origin_account = await sqlbot_decrypt (form_data .username )
21+ origin_pwd = await sqlbot_decrypt (form_data .password )
22+ user : BaseUserDTO = authenticate (session = session , account = origin_account , password = origin_pwd )
2023 if not user :
2124 raise HTTPException (status_code = 400 , detail = trans ('i18n_login.account_pwd_error' ))
2225 if not user .oid or user .oid == 0 :
Original file line number Diff line number Diff line change 1+ from sqlbot_xpack .core import sqlbot_decrypt as xpack_sqlbot_decrypt
2+
3+ async def sqlbot_decrypt (text : str ) -> str :
4+ return await xpack_sqlbot_decrypt (text )
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ async def lifespan(app: FastAPI):
2929 init_sqlbot_cache ()
3030 init_dynamic_cors (app )
3131 SQLBotLogUtil .info ("✅ SQLBot 初始化完成" )
32+ await sqlbot_xpack .core .clean_xpack_cache ()
3233 yield
3334 SQLBotLogUtil .info ("SQLBot 应用关闭" )
3435
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ dependencies = [
3636 " pyyaml (>=6.0.2,<7.0.0)" ,
3737 " fastapi-mcp (>=0.3.4,<0.4.0)" ,
3838 " tabulate>=0.9.0" ,
39- " sqlbot-xpack==0.0.3.8 " ,
39+ " sqlbot-xpack==0.0.3.9 " ,
4040 " fastapi-cache2>=0.2.2" ,
4141 " sqlparse>=0.5.3" ,
4242 " redis>=6.2.0" ,
Original file line number Diff line number Diff line change @@ -8,4 +8,5 @@ export {}
88declare global {
99 const ElMessage : typeof import ( 'element-plus-secondary/es' ) [ 'ElMessage' ]
1010 const ElMessageBox : typeof import ( 'element-plus-secondary/es' ) [ 'ElMessageBox' ]
11+ const LicenseGenerator : any
1112}
Original file line number Diff line number Diff line change 11import { request } from '@/utils/request'
2-
32export const AuthApi = {
4- login : ( credentials : { username : string ; password : string } ) =>
5- request . post < {
3+ login : ( credentials : { username : string ; password : string } ) => {
4+ const entryCredentials = {
5+ username : LicenseGenerator . sqlbotEncrypt ( credentials . username ) ,
6+ password : LicenseGenerator . sqlbotEncrypt ( credentials . password ) ,
7+ }
8+ return request . post < {
69 data : any
710 token : string
8- } > ( '/login/access-token' , credentials , {
11+ } > ( '/login/access-token' , entryCredentials , {
912 headers : {
1013 'Content-Type' : 'application/x-www-form-urlencoded' ,
1114 } ,
12- } ) ,
15+ } )
16+ } ,
1317 logout : ( ) => request . post ( '/auth/logout' ) ,
1418 info : ( ) => request . get ( '/user/info' ) ,
1519}
Original file line number Diff line number Diff line change @@ -50,12 +50,10 @@ const loadXpackStatic = () => {
5050 if ( document . getElementById ( 'sqlbot_xpack_static' ) ) {
5151 return Promise . resolve ( )
5252 }
53- const url = ' /xpack_static/license-generator.umd.js'
53+ const url = ` /xpack_static/license-generator.umd.js?t= ${ Date . now ( ) } `
5454 return new Promise ( ( resolve , reject ) => {
5555 request
5656 . loadRemoteScript ( url , 'sqlbot_xpack_static' , ( ) => {
57- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
58- // @ts -ignore
5957 LicenseGenerator ?. init ( import . meta. env . VITE_API_BASE_URL ) . then ( ( ) => {
6058 resolve ( true )
6159 } )
Original file line number Diff line number Diff line change @@ -99,8 +99,7 @@ class HttpService {
9999 // Skip auth for xpack_static requests
100100 return config
101101 }
102- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
103- // @ts -ignore
102+
104103 const request_key = LicenseGenerator . generate ( )
105104 config . headers [ 'X-SQLBOT-KEY' ] = request_key
106105
@@ -266,8 +265,6 @@ class HttpService {
266265 heads [ 'X-SQLBOT-ASSISTANT-ONLINE' ] = assistantStore . getOnline
267266 }
268267 }
269- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
270- // @ts -ignore
271268 const request_key = LicenseGenerator . generate ( )
272269 heads [ 'X-SQLBOT-KEY' ] = request_key
273270
Original file line number Diff line number Diff line change 5151 @selection-change =" handleSelectionChange"
5252 >
5353 <el-table-column type =" selection" width =" 55" />
54- <el-table-column prop =" name" :label =" $t('user.name')" width =" 280" />
55- <el-table-column prop =" account" :label =" $t('user.account')" width =" 280" />
54+ <el-table-column prop =" name" show-overflow-tooltip :label =" $t('user.name')" width =" 280" />
55+ <el-table-column
56+ prop =" account"
57+ show-overflow-tooltip
58+ :label =" $t('user.account')"
59+ width =" 280"
60+ />
5661 <el-table-column prop =" status" :label =" $t('user.user_status')" width =" 180" >
5762 <template #default =" scope " >
5863 <div class =" user-status-container" :class =" [scope.row.status ? 'active' : 'disabled']" >
You can’t perform that action at this time.
0 commit comments