Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Sep 14, 2024
1 parent 5a6733f commit 5229a01
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def convert_int(cls, value):
def validate_api_token(cls, v):
if not v:
new_token = secrets.token_urlsafe(16)
logger.info(f"API_TOKEN 未设置,已随机生成新的 API_TOKEN:{new_token}")
logger.info(f"API_TOKEN未设置,已随机生成新的 API_TOKEN:{new_token}")
set_key(str(SystemUtils.get_env_path()), "API_TOKEN", new_token)
return new_token
elif len(v) < 16:
Expand Down
7 changes: 2 additions & 5 deletions database/versions/294b007932ef_2_0_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"""

import random
import string
import secrets

from app.core.config import settings
from app.core.security import get_password_hash
Expand All @@ -32,10 +31,8 @@ def upgrade() -> None:
# 初始化超级管理员
_user = User.get_by_name(db=db, name=settings.SUPERUSER)
if not _user:
# 定义包含数字、大小写字母的字符集合
characters = string.ascii_letters + string.digits
# 生成随机密码
random_password = ''.join(random.choice(characters) for _ in range(16))
random_password = secrets.token_urlsafe(16)
logger.info(
f"【超级管理员初始密码】{random_password} 请登录系统后在设定中修改。 注:该密码只会显示一次,请注意保存。")
_user = User(
Expand Down

0 comments on commit 5229a01

Please sign in to comment.