🔧 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:
Gabriel Luiz Freitas Almeida 2023-09-25 15:54:55 -03:00
commit a5da416bc4
3 changed files with 10 additions and 3 deletions

View file

@ -13,7 +13,7 @@ from sqlalchemy.exc import IntegrityError
from sqlmodel import Session, select
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 (
get_current_active_superuser,
get_current_active_user,
@ -32,6 +32,7 @@ router = APIRouter(tags=["Users"], prefix="/users")
def add_user(
user: UserCreate,
session: Session = Depends(get_session),
settings_service=Depends(get_settings_service),
) -> User:
"""
Add a new user to the database.
@ -39,7 +40,7 @@ def add_user(
new_user = User.from_orm(user)
try:
new_user.password = get_password_hash(user.password)
new_user.is_active = settings_service.settings.NEW_USER_IS_ACTIVE
session.add(new_user)
session.commit()
session.refresh(new_user)

View file

@ -7,6 +7,8 @@ from langflow.services.cache.base import BaseCacheService
import pickle
from loguru import logger
class InMemoryCache(BaseCacheService, Service):
@ -221,7 +223,10 @@ class RedisCache(BaseCacheService, Service):
"RedisCache requires the redis-py package."
" Please install Langflow with the deploy extra: pip install langflow[deploy]"
) 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.expiration_time = expiration_time

View file

@ -35,6 +35,7 @@ class AuthSettings(BaseSettings):
# If AUTO_LOGIN = True
# > The application does not request login and logs in automatically as a super user.
AUTO_LOGIN: bool = False
NEW_USER_IS_ACTIVE: bool = False
SUPERUSER: str = DEFAULT_SUPERUSER
SUPERUSER_PASSWORD: str = DEFAULT_SUPERUSER_PASSWORD