🔧 fix(users.py): add support for NEW_USER_IS_ACTIVE setting to determine if new users should be active by default
🔧 fix(cache/manager.py): add warning log message to inform users that RedisCache is experimental and may not work as expected 🔧 fix(settings/auth.py): add NEW_USER_IS_ACTIVE setting to determine if new users should be active by default
This commit is contained in:
parent
d8ba8f0746
commit
a5da416bc4
3 changed files with 10 additions and 3 deletions
|
|
@ -13,7 +13,7 @@ from sqlalchemy.exc import IntegrityError
|
||||||
from sqlmodel import Session, select
|
from sqlmodel import Session, select
|
||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
|
||||||
from langflow.services.getters import get_session
|
from langflow.services.getters import get_session, get_settings_service
|
||||||
from langflow.services.auth.utils import (
|
from langflow.services.auth.utils import (
|
||||||
get_current_active_superuser,
|
get_current_active_superuser,
|
||||||
get_current_active_user,
|
get_current_active_user,
|
||||||
|
|
@ -32,6 +32,7 @@ router = APIRouter(tags=["Users"], prefix="/users")
|
||||||
def add_user(
|
def add_user(
|
||||||
user: UserCreate,
|
user: UserCreate,
|
||||||
session: Session = Depends(get_session),
|
session: Session = Depends(get_session),
|
||||||
|
settings_service=Depends(get_settings_service),
|
||||||
) -> User:
|
) -> User:
|
||||||
"""
|
"""
|
||||||
Add a new user to the database.
|
Add a new user to the database.
|
||||||
|
|
@ -39,7 +40,7 @@ def add_user(
|
||||||
new_user = User.from_orm(user)
|
new_user = User.from_orm(user)
|
||||||
try:
|
try:
|
||||||
new_user.password = get_password_hash(user.password)
|
new_user.password = get_password_hash(user.password)
|
||||||
|
new_user.is_active = settings_service.settings.NEW_USER_IS_ACTIVE
|
||||||
session.add(new_user)
|
session.add(new_user)
|
||||||
session.commit()
|
session.commit()
|
||||||
session.refresh(new_user)
|
session.refresh(new_user)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ from langflow.services.cache.base import BaseCacheService
|
||||||
|
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
|
|
||||||
class InMemoryCache(BaseCacheService, Service):
|
class InMemoryCache(BaseCacheService, Service):
|
||||||
|
|
||||||
|
|
@ -221,7 +223,10 @@ class RedisCache(BaseCacheService, Service):
|
||||||
"RedisCache requires the redis-py package."
|
"RedisCache requires the redis-py package."
|
||||||
" Please install Langflow with the deploy extra: pip install langflow[deploy]"
|
" Please install Langflow with the deploy extra: pip install langflow[deploy]"
|
||||||
) from exc
|
) from exc
|
||||||
|
logger.warning(
|
||||||
|
"RedisCache is an experimental feature and may not work as expected."
|
||||||
|
" Please report any issues to our GitHub repository."
|
||||||
|
)
|
||||||
self._client = redis.StrictRedis(host=host, port=port, db=db)
|
self._client = redis.StrictRedis(host=host, port=port, db=db)
|
||||||
self.expiration_time = expiration_time
|
self.expiration_time = expiration_time
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ class AuthSettings(BaseSettings):
|
||||||
# If AUTO_LOGIN = True
|
# If AUTO_LOGIN = True
|
||||||
# > The application does not request login and logs in automatically as a super user.
|
# > The application does not request login and logs in automatically as a super user.
|
||||||
AUTO_LOGIN: bool = False
|
AUTO_LOGIN: bool = False
|
||||||
|
NEW_USER_IS_ACTIVE: bool = False
|
||||||
SUPERUSER: str = DEFAULT_SUPERUSER
|
SUPERUSER: str = DEFAULT_SUPERUSER
|
||||||
SUPERUSER_PASSWORD: str = DEFAULT_SUPERUSER_PASSWORD
|
SUPERUSER_PASSWORD: str = DEFAULT_SUPERUSER_PASSWORD
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue