feat(system):优化后端

1.新增后端测试
2.增加了后端的加密
3.增加了i18n(国际化)
This commit is contained in:
2026-05-31 15:39:34 +00:00
parent affe460180
commit 99520c69d7
118 changed files with 8174 additions and 1491 deletions
+9 -3
View File
@@ -12,10 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Annotated
from fastapi import Depends, HTTPException
from fastapi import Depends, HTTPException, Request
from kilostar.utils.access import Accessor, TokenData
from kilostar.core.postgres_database.model import UserAuthority
from kilostar.utils.ray_hook import ray_actor_hook
from kilostar.utils.i18n import t
def _user_not_found_detail(request: Request | None = None) -> str:
loc = request.headers.get("accept-language") if request else None
return t("user_not_found", accept_language=loc)
async def get_authority(user_id: str) -> UserAuthority:
@@ -29,12 +35,12 @@ async def get_authority(user_id: str) -> UserAuthority:
)
return user_authority
except UserNotExistError:
raise HTTPException(status_code=401, detail="用户不存在或已被删除,请重新登录")
raise HTTPException(status_code=401, detail=t("user_not_found"))
except Exception as e:
# Check if it's a RayTaskError wrapping UserNotExistError
if "UserNotExistError" in str(e):
raise HTTPException(
status_code=401, detail="用户不存在或已被删除,请重新登录"
status_code=401, detail=t("user_not_found")
)
raise