mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 09:00:52 +03:00
Fix apikey not URL safe (#2602)
This commit is contained in:
@@ -120,17 +120,18 @@ const getAllChatflows = async (type?: ChatflowType): Promise<IChatFlow[]> => {
|
||||
}
|
||||
}
|
||||
|
||||
const getChatflowByApiKey = async (apiKeyId: string): Promise<any> => {
|
||||
const getChatflowByApiKey = async (apiKeyId: string, keyonly?: unknown): Promise<any> => {
|
||||
try {
|
||||
// Here we only get chatflows that are bounded by the apikeyid and chatflows that are not bounded by any apikey
|
||||
const appServer = getRunningExpressApp()
|
||||
const dbResponse = await appServer.AppDataSource.getRepository(ChatFlow)
|
||||
let query = appServer.AppDataSource.getRepository(ChatFlow)
|
||||
.createQueryBuilder('cf')
|
||||
.where('cf.apikeyid = :apikeyid', { apikeyid: apiKeyId })
|
||||
.orWhere('cf.apikeyid IS NULL')
|
||||
.orWhere('cf.apikeyid = ""')
|
||||
.orderBy('cf.name', 'ASC')
|
||||
.getMany()
|
||||
if (keyonly === undefined) {
|
||||
query = query.orWhere('cf.apikeyid IS NULL').orWhere('cf.apikeyid = ""')
|
||||
}
|
||||
|
||||
const dbResponse = await query.orderBy('cf.name', 'ASC').getMany()
|
||||
if (dbResponse.length < 1) {
|
||||
throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Chatflow not found in the database!`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user