Skip to content

Commit 7317cb1

Browse files
authored
fix user not found error (#1369)
1 parent 6f90ecc commit 7317cb1

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

.changeset/busy-yaks-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@inkeep/agents-manage-ui": patch
3+
---
4+
5+
fix user not found error

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ OAUTH_CLIENT_LOGO_URI=https://inkeep.com/images/logos/inkeep-logo-blue.svg
7272
7373
# INKEEP_AGENTS_MANAGE_UI_PASSWORD=adminADMIN!@12
7474
DISABLE_AUTH=true
75+
PUBLIC_DISABLE_AUTH=true
7576

7677
# AUTH0_DOMAIN=
7778
# NEXT_PUBLIC_AUTH0_DOMAIN=

agents-manage-ui/src/components/mcp-servers/selection/scope-selection-dialog.tsx

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use client';
22

3-
import { User, Users } from 'lucide-react';
3+
import { Info, User, Users } from 'lucide-react';
44
import { useState } from 'react';
5+
import { Alert, AlertDescription } from '@/components/ui/alert';
56
import { Button } from '@/components/ui/button';
67
import {
78
Dialog,
@@ -11,6 +12,7 @@ import {
1112
DialogHeader,
1213
DialogTitle,
1314
} from '@/components/ui/dialog';
15+
import { useRuntimeConfig } from '@/contexts/runtime-config-context';
1416
import { type CredentialScope, CredentialScopeEnum } from '../form/validation';
1517

1618
interface ScopeSelectionDialogProps {
@@ -27,6 +29,10 @@ export function ScopeSelectionDialog({
2729
onConfirm,
2830
}: ScopeSelectionDialogProps) {
2931
const [selectedScope, setSelectedScope] = useState<CredentialScope>(CredentialScopeEnum.project);
32+
const { PUBLIC_DISABLE_AUTH } = useRuntimeConfig();
33+
34+
const isAuthDisabled = PUBLIC_DISABLE_AUTH === 'true';
35+
const isUserScopeDisabled = isAuthDisabled;
3036

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

6571
<button
6672
type="button"
67-
onClick={() => setSelectedScope(CredentialScopeEnum.user)}
73+
onClick={() => {
74+
if (!isUserScopeDisabled) {
75+
setSelectedScope(CredentialScopeEnum.user);
76+
}
77+
}}
78+
disabled={isUserScopeDisabled}
6879
className={`flex items-start gap-4 p-4 rounded-lg border-2 text-left transition-colors ${
69-
selectedScope === CredentialScopeEnum.user
70-
? 'border-primary bg-primary/5'
71-
: 'border-border hover:border-primary/50'
80+
isUserScopeDisabled
81+
? 'opacity-50 cursor-not-allowed border-border bg-muted/30'
82+
: selectedScope === CredentialScopeEnum.user
83+
? 'border-primary bg-primary/5'
84+
: 'border-border hover:border-primary/50'
7285
}`}
7386
>
74-
<User className="w-5 h-5 mt-0.5 text-muted-foreground" />
87+
<User className="h-4 w-4 mt-1 shrink-0 text-muted-foreground" />
7588
<div className="flex-1">
7689
<div className="font-medium">User (Per-user)</div>
7790
<p className="text-sm text-muted-foreground mt-1">
7891
Each team member connects their own account. No authentication required now.
7992
</p>
8093
</div>
8194
</button>
95+
96+
{isUserScopeDisabled && (
97+
<Alert variant="default" className="bg-muted/50">
98+
<Info className="h-4 w-4" />
99+
<AlertDescription>
100+
User-scoped credentials require authentication to be enabled.
101+
</AlertDescription>
102+
</Alert>
103+
)}
82104
</div>
83105

84106
<DialogFooter>

agents-manage-ui/src/hooks/use-oauth-login.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ export function useOAuthLogin({
155155
toolName: string;
156156
credentialScope?: 'project' | 'user';
157157
}): Promise<void> => {
158-
if (!user) {
159-
throw new Error('User not found');
160-
}
161-
162158
const authResult = await openNangoConnectHeadless({
163159
mcpServerUrl,
164160
providerUniqueKey: `${generateIdFromName(toolName)}_${toolId.slice(0, 4)}`,
@@ -167,6 +163,14 @@ export function useOAuthLogin({
167163

168164
const isUserScoped = credentialScope === 'user';
169165

166+
let userId: string | undefined;
167+
if (isUserScoped) {
168+
if (!user) {
169+
throw new Error('User not found');
170+
}
171+
userId = user.id;
172+
}
173+
170174
const newCredentialData = {
171175
id: generateId(),
172176
name: toolName,
@@ -176,7 +180,7 @@ export function useOAuthLogin({
176180
// For user-scoped: set toolId and userId on the credential reference
177181
...(isUserScoped && {
178182
toolId,
179-
userId: user.id,
183+
userId,
180184
}),
181185
retrievalParams: {
182186
connectionId: authResult.connectionId,

0 commit comments

Comments
 (0)