Skip to content

Improved login experience#4178

Merged
pablonyx merged 20 commits intomainfrom
improved_login_experience
Mar 9, 2025
Merged

Improved login experience#4178
pablonyx merged 20 commits intomainfrom
improved_login_experience

Conversation

@pablonyx
Copy link
Copy Markdown
Contributor

@pablonyx pablonyx commented Mar 3, 2025

Description

Must go in in concert with these control plane changes: https://github.com/onyx-dot-app/danswer-control-plane/pull/27

Fixes https://linear.app/danswer/issue/DAN-1513/improved-tenant-switching-suggestion-to-join-existing-tenant

Logic

  • UserTenantMapping now has an active column to track which tenant a user is currently active in
  • If invited to a tenant, will have a non-active entry (these should be short lived)

New Flows

  • On first creating an account, if an existing team with the same email domain exists, users are prompted to request to join
  • Admins can review and approve/deny join requests from a new "Pending Users" tab
  • When approved, users are prompted to join the team
  • Users can accept or reject invitations to teams

Changes

  • Refactored tenant APIs into dedicated modules
  • Added migration to support the new active status in user-tenant mappings
  • Pending / invited user distinction
  • New invitation flows

How Has This Been Tested?

All flows

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

@pablonyx pablonyx requested a review from a team as a code owner March 3, 2025 21:26
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 9, 2025 0:25am

Comment on lines +3 to +17
from fastapi import HTTPException
from fastapi import Response
from sqlalchemy.exc import IntegrityError

from ee.onyx.auth.users import generate_anonymous_user_jwt_token
from ee.onyx.configs.app_configs import ANONYMOUS_USER_COOKIE_NAME
from ee.onyx.server.tenants.anonymous_user_path import get_anonymous_user_path
from ee.onyx.server.tenants.anonymous_user_path import (
get_tenant_id_for_anonymous_user_path,
)
from ee.onyx.server.tenants.anonymous_user_path import modify_anonymous_user_path
from ee.onyx.server.tenants.anonymous_user_path import validate_anonymous_user_path
from ee.onyx.server.tenants.models import AnonymousUserPath
from onyx.auth.users import anonymous_user_enabled
from onyx.auth.users import current_admin_user
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all just migrated from the existing structure. Happy to re-org if there is a better structure

Comment on lines +15 to +16
# Note: We don't add a prefix here as each router already has the /tenants prefix
router = APIRouter()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify all the tenant-related routing into a single tenant router

Copy link
Copy Markdown
Contributor

@rkuo-danswer rkuo-danswer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a user is invited, logs in, and accepts, he is presented with a flow that asks for Reauthentication and a "Password". It's unclear if the user is being asked for his old password or to create a new one (i assume it's to create a new one).

After clicking join, there is a brief green notification in the bottom right that asks the user to log in, which doesn't quite make sense as the user is then logged in automatically.

Comment thread backend/ee/onyx/server/tenants/billing.py Outdated
Comment thread web/src/components/modals/NewTenantModal.tsx Outdated
Comment thread web/src/components/modals/ConfirmEntityModal.tsx
Comment thread web/src/app/auth/join/page.tsx Outdated
Comment thread backend/onyx/auth/users.py Outdated
Comment thread backend/ee/onyx/server/tenants/user_mapping.py
Comment thread backend/ee/onyx/server/tenants/user_mapping.py
Comment thread backend/ee/onyx/server/tenants/user_invitations_api.py Outdated
Comment thread backend/ee/onyx/server/tenants/tenant_management_api.py
Comment thread backend/ee/onyx/server/tenants/billing_api.py
@pablonyx pablonyx force-pushed the improved_login_experience branch from 7ccb04a to 2317dfd Compare March 9, 2025 00:18
@pablonyx pablonyx enabled auto-merge March 9, 2025 00:20
@pablonyx pablonyx added this pull request to the merge queue Mar 9, 2025
Merged via the queue into main with commit 06dcc28 Mar 9, 2025
9 of 10 checks passed
This was referenced Mar 11, 2025
@rkuo-danswer rkuo-danswer deleted the improved_login_experience branch May 12, 2025 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants