Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(access-control): per-group chat-deploy auth modes + polish#5818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
7c55574691a49625985a8032ee8597b8db6File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -33,6 +33,7 @@ import { | ||
| useUpdateChat, | ||
| } from '@/hooks/queries/chats' | ||
| import type { ChatDetail } from '@/hooks/queries/deployments' | ||
| import { usePermissionConfig } from '@/hooks/use-permission-config' | ||
| import { useIdentifierValidation } from './hooks' | ||
| import { | ||
| getPasswordHelperText, | ||
| @@ -371,6 +372,7 @@ export function ChatDeploy({ | ||
| <AuthSelector | ||
| key={`${existingChat?.id ?? 'new'}-${formInitCounter}`} | ||
| authType={formData.authType} | ||
| savedAuthType={existingChat?.authType as AuthType | undefined} | ||
| password={formData.password} | ||
| emails={formData.emails} | ||
| onAuthTypeChange={(type) => updateField('authType', type)} | ||
| @@ -583,6 +585,8 @@ function IdentifierInput({ | ||
| interface AuthSelectorProps { | ||
| authType: AuthType | ||
| /** The persisted mode of an existing chat, kept selectable even if newly disallowed. */ | ||
| savedAuthType?: AuthType | ||
| password: string | ||
| emails: string[] | ||
| onAuthTypeChange: (type: AuthType) => void | ||
| @@ -602,6 +606,7 @@ const AUTH_LABELS: Record<AuthType, string> = { | ||
| function AuthSelector({ | ||
| authType, | ||
| savedAuthType, | ||
| password, | ||
| emails, | ||
| onAuthTypeChange, | ||
| @@ -671,10 +676,26 @@ function AuthSelector({ | ||
| } | ||
| } | ||
| const ssoEnabled = isTruthy(getEnv('NEXT_PUBLIC_SSO_ENABLED')) | ||
| const authOptions = ssoEnabled | ||
| ? (['public', 'password', 'email', 'sso'] as const) | ||
| : (['public', 'password', 'email'] as const) | ||
| const { config: permissionConfig } = usePermissionConfig() | ||
| const allowedAuthTypes = permissionConfig.allowedChatDeployAuthTypes | ||
| const ssoAvailable = | ||
| isTruthy(getEnv('NEXT_PUBLIC_SSO_ENABLED')) || | ||
| savedAuthType === 'sso' || | ||
| (allowedAuthTypes?.includes('sso') ?? false) | ||
| const baseAuthOptions: AuthType[] = ssoAvailable | ||
| ? ['public', 'password', 'email', 'sso'] | ||
| : ['public', 'password', 'email'] | ||
| const authOptions = baseAuthOptions.filter( | ||
| (type) => allowedAuthTypes === null || allowedAuthTypes.includes(type) || type === savedAuthType | ||
| ) | ||
waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| useEffect(() => { | ||
| if (authOptions.length > 0 && !authOptions.includes(authType)) { | ||
| onAuthTypeChange(authOptions[0]) | ||
| } | ||
| }, [authOptions, authType, onAuthTypeChange]) | ||
waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return ( | ||
| <div className='space-y-4'> | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.