mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-09 03:26:38 +08:00
no req
This commit is contained in:
parent
d86b7ddd50
commit
ee042d9dbe
@ -29,6 +29,10 @@ import { incrementAPICallCount } from '../../utils/cloud/redisRestClient';
|
|||||||
// app\client\platforms\openai.ts
|
// app\client\platforms\openai.ts
|
||||||
// app\auth.ts
|
// app\auth.ts
|
||||||
|
|
||||||
|
export async function getMyServerSession() {
|
||||||
|
return await getServerAuthSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export interface OpenAIListModelResponse {
|
export interface OpenAIListModelResponse {
|
||||||
@ -112,9 +116,7 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
const modelIdentifier = modelConfig.model;
|
const modelIdentifier = modelConfig.model;
|
||||||
console.log("API Call: session or email is not available - model: ", modelIdentifier);
|
console.log("API Call: session or email is not available - model: ", modelIdentifier);
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
const session = await getMyServerSession(req);
|
||||||
const session = await getServerAuthSession({ req });
|
|
||||||
|
|
||||||
|
|
||||||
if (session?.user?.email) {
|
if (session?.user?.email) {
|
||||||
// Now you have the user's email from the session
|
// Now you have the user's email from the session
|
||||||
@ -126,14 +128,12 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
// Use the userEmail to increment the API call count
|
// Use the userEmail to increment the API call count
|
||||||
await incrementAPICallCount(userEmail, modelIdentifier, dateKey);
|
await incrementAPICallCount(userEmail, modelIdentifier, dateKey);
|
||||||
|
|
||||||
// ... rest of your API route logic ...
|
|
||||||
res.status(200).json({ success: true });
|
|
||||||
} else {
|
} else {
|
||||||
// Handle cases where the session or email is not available
|
// Handle cases where the session or email is not available
|
||||||
console.log("API Call: session or email is not available - model: ", modelIdentifier);
|
console.log("API Call: session or email is not available - model: ", modelIdentifier);
|
||||||
res.status(401).json({ error: "Unauthorized" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
// export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
// Retrieve the session using getServerAuthSession
|
// Retrieve the session using getServerAuthSession
|
||||||
|
Loading…
Reference in New Issue
Block a user