@@ -8,7 +8,7 @@ import type { ChatMessage } from './chatgpt'
88import { abortChatProcess , chatConfig , chatReplyProcess , containsSensitiveWords , initAuditService } from './chatgpt'
99import { auth , getUserId } from './middleware/auth'
1010import { clearApiKeyCache , clearConfigCache , getApiKeys , getCacheApiKeys , getCacheConfig , getOriginConfig } from './storage/config'
11- import type { AuditConfig , CHATMODEL , ChatInfo , ChatOptions , Config , KeyConfig , MailConfig , SiteConfig , UserInfo } from './storage/model'
11+ import type { AuditConfig , CHATMODEL , ChatInfo , ChatOptions , Config , KeyConfig , MailConfig , SiteConfig , UserConfig , UserInfo } from './storage/model'
1212import { Status , UsageResponse , UserRole , chatModelOptions } from './storage/model'
1313import {
1414 clearChat ,
@@ -557,8 +557,18 @@ router.post('/session', async (req, res) => {
557557 key : string
558558 value : string
559559 } [ ] = [ ]
560+ let userInfo : { name : string ; description : string ; avatar : string ; userId : string ; root : boolean ; config : UserConfig }
560561 if ( userId != null ) {
561562 const user = await getUserById ( userId )
563+ userInfo = {
564+ name : user . name ,
565+ description : user . description ,
566+ avatar : user . avatar ,
567+ userId : user . _id . toString ( ) ,
568+ root : user . roles . includes ( UserRole . Admin ) ,
569+ config : user . config ,
570+ }
571+
562572 const keys = ( await getCacheApiKeys ( ) ) . filter ( d => hasAnyRole ( d . userRoles , user . roles ) )
563573
564574 const count : { key : string ; count : number } [ ] = [ ]
@@ -596,6 +606,7 @@ router.post('/session', async (req, res) => {
596606 title : config . siteConfig . siteTitle ,
597607 chatModels,
598608 allChatModels : chatModelOptions ,
609+ userInfo,
599610 } ,
600611 } )
601612 }
0 commit comments