Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/busy-yaks-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inkeep/agents-manage-ui": patch
---

fix user not found error
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ OAUTH_CLIENT_LOGO_URI=https://inkeep.com/images/logos/inkeep-logo-blue.svg
# INKEEP_AGENTS_MANAGE_UI_USERNAME=admin@example.com
# INKEEP_AGENTS_MANAGE_UI_PASSWORD=adminADMIN!@12
DISABLE_AUTH=true
PUBLIC_DISABLE_AUTH=true

# AUTH0_DOMAIN=
# NEXT_PUBLIC_AUTH0_DOMAIN=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use client';

import { User, Users } from 'lucide-react';
import { Info, User, Users } from 'lucide-react';
import { useState } from 'react';
import { Alert, AlertDescription } from '@/components/ui/alert';
import { Button } from '@/components/ui/button';
import {
Dialog,
Expand All @@ -11,6 +12,7 @@ import {
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
import { useRuntimeConfig } from '@/contexts/runtime-config-context';
import { type CredentialScope, CredentialScopeEnum } from '../form/validation';

interface ScopeSelectionDialogProps {
Expand All @@ -27,6 +29,10 @@ export function ScopeSelectionDialog({
onConfirm,
}: ScopeSelectionDialogProps) {
const [selectedScope, setSelectedScope] = useState<CredentialScope>(CredentialScopeEnum.project);
const { PUBLIC_DISABLE_AUTH } = useRuntimeConfig();

const isAuthDisabled = PUBLIC_DISABLE_AUTH === 'true';
const isUserScopeDisabled = isAuthDisabled;

const handleConfirm = () => {
onConfirm(selectedScope);
Expand All @@ -53,7 +59,7 @@ export function ScopeSelectionDialog({
: 'border-border hover:border-primary/50'
}`}
>
<Users className="w-5 h-5 mt-0.5 text-muted-foreground" />
<Users className="h-4 w-4 mt-1 shrink-0 text-muted-foreground" />
<div className="flex-1">
<div className="font-medium">Project (Shared)</div>
<p className="text-sm text-muted-foreground mt-1">
Expand All @@ -64,21 +70,37 @@ export function ScopeSelectionDialog({

<button
type="button"
onClick={() => setSelectedScope(CredentialScopeEnum.user)}
onClick={() => {
if (!isUserScopeDisabled) {
setSelectedScope(CredentialScopeEnum.user);
}
}}
disabled={isUserScopeDisabled}
className={`flex items-start gap-4 p-4 rounded-lg border-2 text-left transition-colors ${
selectedScope === CredentialScopeEnum.user
? 'border-primary bg-primary/5'
: 'border-border hover:border-primary/50'
isUserScopeDisabled
? 'opacity-50 cursor-not-allowed border-border bg-muted/30'
: selectedScope === CredentialScopeEnum.user
? 'border-primary bg-primary/5'
: 'border-border hover:border-primary/50'
}`}
>
<User className="w-5 h-5 mt-0.5 text-muted-foreground" />
<User className="h-4 w-4 mt-1 shrink-0 text-muted-foreground" />
<div className="flex-1">
<div className="font-medium">User (Per-user)</div>
<p className="text-sm text-muted-foreground mt-1">
Each team member connects their own account. No authentication required now.
</p>
</div>
</button>

{isUserScopeDisabled && (
<Alert variant="default" className="bg-muted/50">
<Info className="h-4 w-4" />
<AlertDescription>
User-scoped credentials require authentication to be enabled.
</AlertDescription>
</Alert>
)}
</div>

<DialogFooter>
Expand Down
14 changes: 9 additions & 5 deletions agents-manage-ui/src/hooks/use-oauth-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ export function useOAuthLogin({
toolName: string;
credentialScope?: 'project' | 'user';
}): Promise<void> => {
if (!user) {
throw new Error('User not found');
}

const authResult = await openNangoConnectHeadless({
mcpServerUrl,
providerUniqueKey: `${generateIdFromName(toolName)}_${toolId.slice(0, 4)}`,
Expand All @@ -167,6 +163,14 @@ export function useOAuthLogin({

const isUserScoped = credentialScope === 'user';

let userId: string | undefined;
if (isUserScoped) {
if (!user) {
throw new Error('User not found');
}
userId = user.id;
}

const newCredentialData = {
id: generateId(),
name: toolName,
Expand All @@ -176,7 +180,7 @@ export function useOAuthLogin({
// For user-scoped: set toolId and userId on the credential reference
...(isUserScoped && {
toolId,
userId: user.id,
userId,
}),
retrievalParams: {
connectionId: authResult.connectionId,
Expand Down
Loading