mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 20:19:12 +08:00
fix: account.id should account_id (#11628)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
parent
924b4fe742
commit
8e3d60c359
@ -9,11 +9,11 @@ import uuid
|
|||||||
from collections.abc import Generator, Mapping
|
from collections.abc import Generator, Mapping
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union, cast
|
||||||
from zoneinfo import available_timezones
|
from zoneinfo import available_timezones
|
||||||
|
|
||||||
from flask import Response, stream_with_context
|
from flask import Response, stream_with_context
|
||||||
from flask_restful import fields
|
from flask_restful import fields # type: ignore
|
||||||
|
|
||||||
from configs import dify_config
|
from configs import dify_config
|
||||||
from core.app.features.rate_limiting.rate_limit import RateLimitGenerator
|
from core.app.features.rate_limiting.rate_limit import RateLimitGenerator
|
||||||
@ -168,11 +168,11 @@ def generate_string(n):
|
|||||||
|
|
||||||
def extract_remote_ip(request) -> str:
|
def extract_remote_ip(request) -> str:
|
||||||
if request.headers.get("CF-Connecting-IP"):
|
if request.headers.get("CF-Connecting-IP"):
|
||||||
return request.headers.get("Cf-Connecting-Ip")
|
return cast(str, request.headers.get("Cf-Connecting-Ip"))
|
||||||
elif request.headers.getlist("X-Forwarded-For"):
|
elif request.headers.getlist("X-Forwarded-For"):
|
||||||
return request.headers.getlist("X-Forwarded-For")[0]
|
return cast(str, request.headers.getlist("X-Forwarded-For")[0])
|
||||||
else:
|
else:
|
||||||
return request.remote_addr
|
return cast(str, request.remote_addr)
|
||||||
|
|
||||||
|
|
||||||
def generate_text_hash(text: str) -> str:
|
def generate_text_hash(text: str) -> str:
|
||||||
@ -221,12 +221,14 @@ class TokenManager:
|
|||||||
token_data.update(additional_data)
|
token_data.update(additional_data)
|
||||||
|
|
||||||
expiry_minutes = dify_config.model_dump().get(f"{token_type.upper()}_TOKEN_EXPIRY_MINUTES")
|
expiry_minutes = dify_config.model_dump().get(f"{token_type.upper()}_TOKEN_EXPIRY_MINUTES")
|
||||||
|
if expiry_minutes is None:
|
||||||
|
raise ValueError(f"Expiry minutes for {token_type} token is not set")
|
||||||
token_key = cls._get_token_key(token, token_type)
|
token_key = cls._get_token_key(token, token_type)
|
||||||
expiry_time = int(expiry_minutes * 60)
|
expiry_time = int(expiry_minutes * 60)
|
||||||
redis_client.setex(token_key, expiry_time, json.dumps(token_data))
|
redis_client.setex(token_key, expiry_time, json.dumps(token_data))
|
||||||
|
|
||||||
if account_id:
|
if account_id:
|
||||||
cls._set_current_token_for_account(account.id, token, token_type, expiry_minutes)
|
cls._set_current_token_for_account(account_id, token, token_type, expiry_minutes)
|
||||||
|
|
||||||
return token
|
return token
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user