feat: Add new ENV VAR for custom error message on error on signup / password change due to password not meeting requirements (#20650)
* add env var for custom auth pw message * Update auth.py * Update auth.py
This commit is contained in:
@@ -455,6 +455,8 @@ except Exception as e:
|
|||||||
r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$"
|
r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,}$"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
PASSWORD_VALIDATION_HINT = os.environ.get("PASSWORD_VALIDATION_HINT", "")
|
||||||
|
|
||||||
|
|
||||||
BYPASS_MODEL_ACCESS_CONTROL = (
|
BYPASS_MODEL_ACCESS_CONTROL = (
|
||||||
os.environ.get("BYPASS_MODEL_ACCESS_CONTROL", "False").lower() == "true"
|
os.environ.get("BYPASS_MODEL_ACCESS_CONTROL", "False").lower() == "true"
|
||||||
|
|||||||
@@ -813,6 +813,8 @@ async def signup(
|
|||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
raise HTTPException(500, detail=ERROR_MESSAGES.CREATE_USER_ERROR)
|
raise HTTPException(500, detail=ERROR_MESSAGES.CREATE_USER_ERROR)
|
||||||
|
except HTTPException:
|
||||||
|
raise
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
log.error(f"Signup error: {str(err)}")
|
log.error(f"Signup error: {str(err)}")
|
||||||
raise HTTPException(500, detail="An internal error occurred during signup.")
|
raise HTTPException(500, detail="An internal error occurred during signup.")
|
||||||
@@ -954,6 +956,8 @@ async def add_user(
|
|||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
raise HTTPException(500, detail=ERROR_MESSAGES.CREATE_USER_ERROR)
|
raise HTTPException(500, detail=ERROR_MESSAGES.CREATE_USER_ERROR)
|
||||||
|
except HTTPException:
|
||||||
|
raise
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
log.error(f"Add user error: {str(err)}")
|
log.error(f"Add user error: {str(err)}")
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ from open_webui.env import (
|
|||||||
ENABLE_PASSWORD_VALIDATION,
|
ENABLE_PASSWORD_VALIDATION,
|
||||||
OFFLINE_MODE,
|
OFFLINE_MODE,
|
||||||
LICENSE_BLOB,
|
LICENSE_BLOB,
|
||||||
|
PASSWORD_VALIDATION_HINT,
|
||||||
PASSWORD_VALIDATION_REGEX_PATTERN,
|
PASSWORD_VALIDATION_REGEX_PATTERN,
|
||||||
REDIS_KEY_PREFIX,
|
REDIS_KEY_PREFIX,
|
||||||
pk,
|
pk,
|
||||||
@@ -173,7 +174,7 @@ def validate_password(password: str) -> bool:
|
|||||||
|
|
||||||
if ENABLE_PASSWORD_VALIDATION:
|
if ENABLE_PASSWORD_VALIDATION:
|
||||||
if not PASSWORD_VALIDATION_REGEX_PATTERN.match(password):
|
if not PASSWORD_VALIDATION_REGEX_PATTERN.match(password):
|
||||||
raise Exception(ERROR_MESSAGES.INVALID_PASSWORD())
|
raise Exception(ERROR_MESSAGES.INVALID_PASSWORD(PASSWORD_VALIDATION_HINT))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user