Bläddra i källkod

bugfix displayname authToken

anhuiqiang 7 timmar sedan
förälder
incheckning
0b185b9133

+ 2 - 1
server/src/user/user.service.ts

@@ -127,7 +127,7 @@ export class UserService implements OnModuleInit {
     const user = await this.usersRepository.save({
       username,
       password: hashedPassword,
-      displayName,
+      displayName: displayName || username,
       isAdmin,
       tenantId: tenantId ?? undefined,
     } as any);
@@ -311,6 +311,7 @@ export class UserService implements OnModuleInit {
       await this.usersRepository.save({
         username: 'admin',
         password: hashedPassword,
+        displayName: 'Admin',
         isAdmin: true,
       });
 

+ 8 - 4
web/components/ChatInterface.tsx

@@ -32,6 +32,7 @@ interface ChatInterfaceProps {
   onPreviewSource?: (source: ChatSource) => void;
   onOpenFile?: (source: ChatSource) => void;
   onHistoryIdCreated?: (historyId: string) => void;
+  authToken?: string; // Add authToken prop
 }
 
 const ChatInterface: React.FC<ChatInterfaceProps> = ({
@@ -50,7 +51,8 @@ const ChatInterface: React.FC<ChatInterfaceProps> = ({
   onHistoryMessagesLoaded,
   onPreviewSource,
   onOpenFile,
-  onHistoryIdCreated
+  onHistoryIdCreated,
+  authToken: propAuthToken // Use prop
 }) => {
   const { t, language } = useLanguage();
   const [messages, setMessages] = useState<Message[]>([]);
@@ -167,8 +169,10 @@ const ChatInterface: React.FC<ChatInterfaceProps> = ({
     setIsLoading(true);
     setMessages((prev) => [...prev, newMessage]);
 
-    const authToken = localStorage.getItem('authToken');
-    if (!authToken) {
+    // Use token from props if available, fallback to localStorage (with correct key)
+    const finalToken = propAuthToken || localStorage.getItem('kb_api_key') || localStorage.getItem('authToken');
+    
+    if (!finalToken) {
       const errorMsg: Message = {
         id: generateUUID(),
         role: Role.MODEL,
@@ -204,7 +208,7 @@ const ChatInterface: React.FC<ChatInterfaceProps> = ({
       const stream = chatService.streamChat(
         userText,
         history,
-        authToken,
+        finalToken,
         language,
         settings.selectedEmbeddingId,
         settings.selectedLLMId, // Pass selected LLM ID

+ 1 - 1
web/components/IndexingModal.tsx

@@ -52,7 +52,7 @@ const IndexingModal: React.FC<IndexingModalProps> = ({
 
   // Get auth token
   const getAuthToken = () => {
-    return localStorage.getItem('authToken') || '';
+    return localStorage.getItem('kb_api_key') || localStorage.getItem('authToken') || '';
   };
 
   // Load config limits when selected model changes

+ 1 - 0
web/components/views/ChatView.tsx

@@ -378,6 +378,7 @@ export const ChatView: React.FC<ChatViewProps> = ({
                                 }
                             }
                         }}
+                        authToken={authToken}
                     />
                 </div>
             </div>