opt: opt debug demo

pull/21891/head
ytqh 1 year ago
parent 4085589695
commit 62ade5ecd3

@ -19,11 +19,6 @@ class DeploymentConfig(BaseSettings):
default=False, default=False,
) )
DEBUG_CODE_FOR_LOGIN: Optional[str] = Field(
description="Default code for login",
default=None,
)
EDITION: str = Field( EDITION: str = Field(
description="Deployment edition of the application (e.g., 'SELF_HOSTED', 'CLOUD')", description="Deployment edition of the application (e.g., 'SELF_HOSTED', 'CLOUD')",
default="SELF_HOSTED", default="SELF_HOSTED",

@ -49,7 +49,17 @@ class SchoolConfig(BaseSettings):
default=None, default=None,
) )
DEBUG_ORG_EMAIL_DOMAIN: Optional[str] = Field(
description="Debug org email domain for DEMO school-level features.",
default=None,
)
DEBUG_ADMIN_PHONE: Optional[str] = Field( DEBUG_ADMIN_PHONE: Optional[str] = Field(
description="Debug admin phone for DEMO school-level features.", description="Debug admin phone for DEMO school-level features.",
default=None, default=None,
) )
DEBUG_CODE_FOR_LOGIN: Optional[str] = Field(
description="Default code for login",
default=None,
)

@ -492,7 +492,7 @@ class AccountService:
if email is None: if email is None:
raise ValueError("Email must be provided.") raise ValueError("Email must be provided.")
if dify_config.DEBUG_CODE_FOR_LOGIN: if dify_config.DEBUG_ORG_EMAIL_DOMAIN and email.endswith(dify_config.DEBUG_ORG_EMAIL_DOMAIN):
code = dify_config.DEBUG_CODE_FOR_LOGIN code = dify_config.DEBUG_CODE_FOR_LOGIN
elif cls.email_code_login_rate_limiter.is_rate_limited(email): elif cls.email_code_login_rate_limiter.is_rate_limited(email):
from controllers.console.auth.error import EmailCodeLoginRateLimitExceededError from controllers.console.auth.error import EmailCodeLoginRateLimitExceededError
@ -507,6 +507,7 @@ class AccountService:
token_type="email_code_login", token_type="email_code_login",
additional_data={"code": code}, additional_data={"code": code},
) )
send_email_code_login_mail_task.delay( send_email_code_login_mail_task.delay(
language=language, language=language,
to=account.email if account else email, to=account.email if account else email,
@ -734,7 +735,7 @@ class AccountService:
Returns a token that can be used to verify the code. Returns a token that can be used to verify the code.
""" """
if dify_config.DEBUG_CODE_FOR_LOGIN: if phone == dify_config.DEBUG_ADMIN_PHONE and dify_config.DEBUG_CODE_FOR_LOGIN:
code = dify_config.DEBUG_CODE_FOR_LOGIN code = dify_config.DEBUG_CODE_FOR_LOGIN
elif cls.phone_code_login_rate_limiter.is_rate_limited(phone): elif cls.phone_code_login_rate_limiter.is_rate_limited(phone):
raise Exception("Phone verification code rate limit exceeded") raise Exception("Phone verification code rate limit exceeded")
@ -749,13 +750,13 @@ class AccountService:
additional_data={"code": code, "phone": phone}, additional_data={"code": code, "phone": phone},
) )
if dify_config.DEBUG_CODE_FOR_LOGIN: if phone == dify_config.DEBUG_ADMIN_PHONE and dify_config.DEBUG_CODE_FOR_LOGIN:
logging.info(f"Mock Code, Skip sending phone verification code to {phone}") logging.info(f"Mock Code, Skip sending phone verification code to {phone}")
else: else:
send_phone_sms_code_login_task.delay(phone=phone, code=code) send_phone_sms_code_login_task.delay(phone=phone, code=code)
cls.phone_code_login_rate_limiter.increment_rate_limit(phone)
logging.info(f"Phone verification code sent to {phone}") logging.info(f"Phone verification code sent to {phone}")
cls.phone_code_login_rate_limiter.increment_rate_limit(phone)
return token return token
@classmethod @classmethod

@ -1056,7 +1056,6 @@ NO_PROXY=
ALLOW_REGISTER=true ALLOW_REGISTER=true
DEFAULT_APP_ID= DEFAULT_APP_ID=
DEFAULT_TENANT_ID= DEFAULT_TENANT_ID=
DEBUG_CODE_FOR_LOGIN=
PHONE_CODE_LOGIN_TOKEN_EXPIRY_MINUTES=5 PHONE_CODE_LOGIN_TOKEN_EXPIRY_MINUTES=5
# User memory generate task interval in minutes # User memory generate task interval in minutes
@ -1075,6 +1074,10 @@ ALIYUN_TEMPLATE_CODE=
IMAGE_GENERATION_DAILY_LIMIT=5 IMAGE_GENERATION_DAILY_LIMIT=5
IMAGE_GENERATION_MIN_CONVERSATION_ROUNDS=10 IMAGE_GENERATION_MIN_CONVERSATION_ROUNDS=10
IMAGE_GENERATION_APP_ID= IMAGE_GENERATION_APP_ID=
# DEBUG ORG
DEBUG_ORG_DOMAIN=test.edu
DEBUG_CODE_FOR_LOGIN=
DEBUG_ADMIN_PHONE= DEBUG_ADMIN_PHONE=
PLUGIN_PYTHON_ENV_INIT_TIMEOUT=120 PLUGIN_PYTHON_ENV_INIT_TIMEOUT=120

@ -461,7 +461,6 @@ x-shared-env: &shared-api-worker-env
ALLOW_REGISTER: ${ALLOW_REGISTER:-true} ALLOW_REGISTER: ${ALLOW_REGISTER:-true}
DEFAULT_APP_ID: ${DEFAULT_APP_ID:-} DEFAULT_APP_ID: ${DEFAULT_APP_ID:-}
DEFAULT_TENANT_ID: ${DEFAULT_TENANT_ID:-} DEFAULT_TENANT_ID: ${DEFAULT_TENANT_ID:-}
DEBUG_CODE_FOR_LOGIN: ${DEBUG_CODE_FOR_LOGIN:-}
PHONE_CODE_LOGIN_TOKEN_EXPIRY_MINUTES: ${PHONE_CODE_LOGIN_TOKEN_EXPIRY_MINUTES:-5} PHONE_CODE_LOGIN_TOKEN_EXPIRY_MINUTES: ${PHONE_CODE_LOGIN_TOKEN_EXPIRY_MINUTES:-5}
NEED_USER_PROFILE_GENERATION_APP_IDS: ${NEED_USER_PROFILE_GENERATION_APP_IDS:-} NEED_USER_PROFILE_GENERATION_APP_IDS: ${NEED_USER_PROFILE_GENERATION_APP_IDS:-}
USER_PROFILE_GENERATE_TASK_INTERVAL: ${USER_PROFILE_GENERATE_TASK_INTERVAL:-5} USER_PROFILE_GENERATE_TASK_INTERVAL: ${USER_PROFILE_GENERATE_TASK_INTERVAL:-5}
@ -474,6 +473,8 @@ x-shared-env: &shared-api-worker-env
IMAGE_GENERATION_DAILY_LIMIT: ${IMAGE_GENERATION_DAILY_LIMIT:-5} IMAGE_GENERATION_DAILY_LIMIT: ${IMAGE_GENERATION_DAILY_LIMIT:-5}
IMAGE_GENERATION_MIN_CONVERSATION_ROUNDS: ${IMAGE_GENERATION_MIN_CONVERSATION_ROUNDS:-10} IMAGE_GENERATION_MIN_CONVERSATION_ROUNDS: ${IMAGE_GENERATION_MIN_CONVERSATION_ROUNDS:-10}
IMAGE_GENERATION_APP_ID: ${IMAGE_GENERATION_APP_ID:-} IMAGE_GENERATION_APP_ID: ${IMAGE_GENERATION_APP_ID:-}
DEBUG_ORG_DOMAIN: ${DEBUG_ORG_DOMAIN:-test.edu}
DEBUG_CODE_FOR_LOGIN: ${DEBUG_CODE_FOR_LOGIN:-}
DEBUG_ADMIN_PHONE: ${DEBUG_ADMIN_PHONE:-} DEBUG_ADMIN_PHONE: ${DEBUG_ADMIN_PHONE:-}
PLUGIN_PYTHON_ENV_INIT_TIMEOUT: ${PLUGIN_PYTHON_ENV_INIT_TIMEOUT:-120} PLUGIN_PYTHON_ENV_INIT_TIMEOUT: ${PLUGIN_PYTHON_ENV_INIT_TIMEOUT:-120}
PLUGIN_MAX_EXECUTION_TIMEOUT: ${PLUGIN_MAX_EXECUTION_TIMEOUT:-600} PLUGIN_MAX_EXECUTION_TIMEOUT: ${PLUGIN_MAX_EXECUTION_TIMEOUT:-600}
@ -537,7 +538,7 @@ services:
# Mount the storage directory to the container, for storing user files. # Mount the storage directory to the container, for storing user files.
- ./volumes/app/storage:/app/api/storage - ./volumes/app/storage:/app/api/storage
# Mount the log directory from the container to the host # Mount the log directory from the container to the host
- ./volumes/app/logs:/app/logs - ./volumes/app/logs:/app/logs
networks: networks:
- ssrf_proxy_network - ssrf_proxy_network
- default - default
@ -568,7 +569,7 @@ services:
# Mount the storage directory to the container, for storing user files. # Mount the storage directory to the container, for storing user files.
- ./volumes/app/storage:/app/api/storage - ./volumes/app/storage:/app/api/storage
# Mount the log directory from the container to the host # Mount the log directory from the container to the host
- ./volumes/app/logs:/app/logs - ./volumes/app/logs:/app/logs
networks: networks:
- ssrf_proxy_network - ssrf_proxy_network
- default - default
@ -593,7 +594,7 @@ services:
# Mount the storage directory to the container, for storing user files. # Mount the storage directory to the container, for storing user files.
- ./volumes/app/storage:/app/api/storage - ./volumes/app/storage:/app/api/storage
# Mount the log directory from the container to the host # Mount the log directory from the container to the host
- ./volumes/app/logs:/app/logs - ./volumes/app/logs:/app/logs
networks: networks:
- ssrf_proxy_network - ssrf_proxy_network
- default - default

Loading…
Cancel
Save