mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-29 05:15:12 +02:00
@@ -55,7 +55,11 @@ logger = logging.getLogger(__name__)
|
|||||||
async def get_or_provision_tenant(
|
async def get_or_provision_tenant(
|
||||||
email: str, referral_source: str | None = None, request: Request | None = None
|
email: str, referral_source: str | None = None, request: Request | None = None
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Get existing tenant ID for an email or create a new tenant if none exists."""
|
"""
|
||||||
|
Get existing tenant ID for an email or create a new tenant if none exists.
|
||||||
|
This function should only be called after we have verified we want this user's tenant to exist.
|
||||||
|
It returns the tenant ID associated with the email, creating a new tenant if necessary.
|
||||||
|
"""
|
||||||
if not MULTI_TENANT:
|
if not MULTI_TENANT:
|
||||||
return POSTGRES_DEFAULT_SCHEMA
|
return POSTGRES_DEFAULT_SCHEMA
|
||||||
|
|
||||||
|
@@ -587,14 +587,20 @@ class UserManager(UUIDIDMixin, BaseUserManager[User, uuid.UUID]):
|
|||||||
) -> Optional[User]:
|
) -> Optional[User]:
|
||||||
email = credentials.username
|
email = credentials.username
|
||||||
|
|
||||||
# Get tenant_id from mapping table
|
tenant_id: str | None = None
|
||||||
tenant_id = await fetch_ee_implementation_or_noop(
|
try:
|
||||||
|
tenant_id = fetch_ee_implementation_or_noop(
|
||||||
"onyx.server.tenants.provisioning",
|
"onyx.server.tenants.provisioning",
|
||||||
"get_or_provision_tenant",
|
"get_tenant_id_for_email",
|
||||||
async_return_default_schema,
|
None,
|
||||||
)(
|
)(
|
||||||
email=email,
|
email=email,
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(
|
||||||
|
f"User attempted to login with invalid credentials: {str(e)}"
|
||||||
|
)
|
||||||
|
|
||||||
if not tenant_id:
|
if not tenant_id:
|
||||||
# User not found in mapping
|
# User not found in mapping
|
||||||
self.password_helper.hash(credentials.password)
|
self.password_helper.hash(credentials.password)
|
||||||
|
@@ -61,6 +61,7 @@ export function EmailPasswordForm({
|
|||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
setIsWorking(false);
|
setIsWorking(false);
|
||||||
|
|
||||||
const errorDetail = (await response.json()).detail;
|
const errorDetail = (await response.json()).detail;
|
||||||
let errorMsg = "Unknown error";
|
let errorMsg = "Unknown error";
|
||||||
if (typeof errorDetail === "object" && errorDetail.reason) {
|
if (typeof errorDetail === "object" && errorDetail.reason) {
|
||||||
@@ -96,12 +97,13 @@ export function EmailPasswordForm({
|
|||||||
} else {
|
} else {
|
||||||
setIsWorking(false);
|
setIsWorking(false);
|
||||||
const errorDetail = (await loginResponse.json()).detail;
|
const errorDetail = (await loginResponse.json()).detail;
|
||||||
|
|
||||||
let errorMsg = "Unknown error";
|
let errorMsg = "Unknown error";
|
||||||
if (errorDetail === "LOGIN_BAD_CREDENTIALS") {
|
if (errorDetail === "LOGIN_BAD_CREDENTIALS") {
|
||||||
errorMsg = "Invalid email or password";
|
errorMsg = "Invalid email or password";
|
||||||
} else if (errorDetail === "NO_WEB_LOGIN_AND_HAS_NO_PASSWORD") {
|
} else if (errorDetail === "NO_WEB_LOGIN_AND_HAS_NO_PASSWORD") {
|
||||||
errorMsg = "Create an account to set a password";
|
errorMsg = "Create an account to set a password";
|
||||||
|
} else if (typeof errorDetail === "string") {
|
||||||
|
errorMsg = errorDetail;
|
||||||
}
|
}
|
||||||
if (loginResponse.status === 429) {
|
if (loginResponse.status === 429) {
|
||||||
errorMsg = "Too many requests. Please try again later.";
|
errorMsg = "Too many requests. Please try again later.";
|
||||||
|
Reference in New Issue
Block a user