feat(account): 账号登录密码支持查看明文——新增GET /accounts/{id}/password解密接口+前端🔑查看弹窗(8s自动关闭/一键复制)
This commit is contained in:
@@ -109,3 +109,17 @@ def delete_account(session: Session, account_id: int) -> Dict[str, int]:
|
||||
session.commit()
|
||||
# 资产端保留原账号名文本(不级联清空),由用户自行处理
|
||||
return {"affected_assets": affected}
|
||||
|
||||
|
||||
def reveal_password(session: Session, account_id: int) -> Dict[str, str]:
|
||||
"""解密返回账号登录密码明文(供前端「查看密码」功能)。
|
||||
|
||||
安全说明:接口受 API Key 保护;密码本可逆加密存储,此处合法解密还原。
|
||||
"""
|
||||
account = _get_account(session, account_id)
|
||||
plain = crypto.decrypt(account.login_password_encrypted)
|
||||
if not plain:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="该账号未配置登录密码"
|
||||
)
|
||||
return {"login_user": account.login_user or "", "password": plain}
|
||||
|
||||
Reference in New Issue
Block a user