mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 17:08:35 +08:00
fix
This commit is contained in:
+1
-1
@@ -206,7 +206,7 @@ class Settings(BaseSettings):
|
|||||||
def validate_api_token(cls, v):
|
def validate_api_token(cls, v):
|
||||||
if not v:
|
if not v:
|
||||||
new_token = secrets.token_urlsafe(16)
|
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)
|
set_key(str(SystemUtils.get_env_path()), "API_TOKEN", new_token)
|
||||||
return new_token
|
return new_token
|
||||||
elif len(v) < 16:
|
elif len(v) < 16:
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ Create Date: 2024-07-20 08:43:40.741251
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import random
|
import secrets
|
||||||
import string
|
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.security import get_password_hash
|
from app.core.security import get_password_hash
|
||||||
@@ -32,10 +31,8 @@ def upgrade() -> None:
|
|||||||
# 初始化超级管理员
|
# 初始化超级管理员
|
||||||
_user = User.get_by_name(db=db, name=settings.SUPERUSER)
|
_user = User.get_by_name(db=db, name=settings.SUPERUSER)
|
||||||
if not _user:
|
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(
|
logger.info(
|
||||||
f"【超级管理员初始密码】{random_password} 请登录系统后在设定中修改。 注:该密码只会显示一次,请注意保存。")
|
f"【超级管理员初始密码】{random_password} 请登录系统后在设定中修改。 注:该密码只会显示一次,请注意保存。")
|
||||||
_user = User(
|
_user = User(
|
||||||
|
|||||||
Reference in New Issue
Block a user