mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
perf: Modify pwd api msg
This commit is contained in:
@@ -120,11 +120,11 @@ async def query(session: SessionDep, trans: Trans, id: int) -> UserEditor:
|
||||
@router.post("")
|
||||
async def create(session: SessionDep, creator: UserCreator, trans: Trans):
|
||||
if check_account_exists(session=session, account=creator.account):
|
||||
raise Exception(trans('i18n_exist', msg = f"{trans('i18n_user.account') [{creator.account}]}"))
|
||||
raise Exception(trans('i18n_exist', msg = f"{trans('i18n_user.account')} [{creator.account}]"))
|
||||
if check_email_exists(session=session, email=creator.email):
|
||||
raise Exception(trans('i18n_exist', msg = f"{trans('i18n_user.email') [{creator.email}]}"))
|
||||
raise Exception(trans('i18n_exist', msg = f"{trans('i18n_user.email')} [{creator.email}]"))
|
||||
if not check_email_format(creator.email):
|
||||
raise Exception(trans('i18n_format_invalid', key = f"{trans('i18n_user.email') [{creator.email}]}"))
|
||||
raise Exception(trans('i18n_format_invalid', key = f"{trans('i18n_user.email')} [{creator.email}]"))
|
||||
data = creator.model_dump(exclude_unset=True)
|
||||
user_model = UserModel.model_validate(data)
|
||||
#user_model.create_time = get_timestamp()
|
||||
@@ -154,9 +154,9 @@ async def update(session: SessionDep, editor: UserEditor, trans: Trans):
|
||||
if editor.account != user_model.account:
|
||||
raise Exception(f"account cannot be changed!")
|
||||
if editor.email != user_model.email and check_email_exists(session=session, account=editor.email):
|
||||
raise Exception(trans('i18n_exist', msg = f"{trans('i18n_user.email') [{editor.email}]}"))
|
||||
raise Exception(trans('i18n_exist', msg = f"{trans('i18n_user.email')} [{editor.email}]"))
|
||||
if not check_email_format(editor.email):
|
||||
raise Exception(trans('i18n_format_invalid', key = f"{trans('i18n_user.email') [{editor.email}]}"))
|
||||
raise Exception(trans('i18n_format_invalid', key = f"{trans('i18n_user.email')} [{editor.email}]"))
|
||||
origin_oid: int = user_model.oid
|
||||
del_stmt = sqlmodel_delete(UserWsModel).where(UserWsModel.uid == editor.id)
|
||||
session.exec(del_stmt)
|
||||
|
||||
@@ -45,9 +45,9 @@ class I18nHelper:
|
||||
|
||||
return current if isinstance(current, str) else key_path
|
||||
|
||||
def __call__(self, key: str, **kwargs) -> str:
|
||||
def __call__(self, arg_key: str, **kwargs) -> str:
|
||||
lang_data = self.i18n.translations.get(self.lang, {})
|
||||
text = self._get_nested_translation(lang_data, key)
|
||||
text = self._get_nested_translation(lang_data, arg_key)
|
||||
|
||||
if kwargs:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user