diff --git a/app/constant.ts b/app/constant.ts index 932382679..498ab17a1 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -262,6 +262,16 @@ export const DEFAULT_MODELS = [ providerType: "openai", }, }, + { + name: "gpt-4-turbo-2024-04-09", + describe: "GPT-4,新版,测试", + available: true, + provider: { + id: "openai", + providerName: "OpenAI", + providerType: "openai", + }, + }, { name: "claude-3-opus-20240229", describe: "claude第三代模型最强版", diff --git a/app/store/config.ts b/app/store/config.ts index 5b332b3f5..56ca4c072 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -137,7 +137,7 @@ export const useAppConfig = createPersistStore( }), { name: StoreKey.Config, - version: 3.8993, + version: 3.8994, migrate(persistedState, version) { const state = persistedState as ChatConfig; @@ -168,7 +168,7 @@ export const useAppConfig = createPersistStore( if (version < 3.8) { state.lastUpdate = Date.now(); } - if (version < 3.8993) { + if (version < 3.8994) { state.lastUpdate = Date.now(); return { ...DEFAULT_CONFIG }; } diff --git a/app/utils/hooks.ts b/app/utils/hooks.ts index a1f67096f..072ff90e2 100644 --- a/app/utils/hooks.ts +++ b/app/utils/hooks.ts @@ -11,6 +11,7 @@ export function useAllModels() { [configStore.customModels, accessStore.customModels].join(","), accessStore.defaultModel, ).filter((m) => !configStore.dontUseModel.includes(m.name as any)); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [ accessStore.customModels, configStore.customModels, diff --git a/lib/auth.ts b/lib/auth.ts index 343ea9f69..e0b0359af 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -10,6 +10,7 @@ import {createTransport} from "nodemailer"; import { comparePassword, hashPassword } from "@/lib/utils"; import {getCurStartEnd} from "@/app/utils/custom"; const SECURE_COOKIES:boolean = !!process.env.SECURE_COOKIES; +type PartialUser = Partial; export const authOptions: NextAuthOptions = { @@ -88,7 +89,7 @@ export const authOptions: NextAuthOptions = { // 判断姓名格式是否符合要求,不符合则拒绝 if (username && isName(username)) { // Any object returned will be saved in `user` property of the JWT - let user:{[key: string]: string} = {} + let user: PartialUser = {} if (isEmail(username)) { user['email'] = username; } else { @@ -97,13 +98,8 @@ export const authOptions: NextAuthOptions = { // 目前用户不存在,则会创建新用户。 let existingUser = await existUser(user); // await insertUser(user) if (!existingUser) { - if (await getSetting("allowNewUser")) { - // 如果不存在,则创建 - existingUser = await insertUser(user); - } else { - // 如果不存在,则报错 - throw new Error("未知用户") - } + user['allowToLogin'] = !!await getSetting("allowNewUser"); + existingUser = await insertUser(user); } // 有密码就校验密码,没有就直接返回用户 (password || existingUser.password) && validatePassword(password, existingUser.password); @@ -236,7 +232,7 @@ async function getSetting(key: string) { } } -async function existUser(user: {[key: string]: string} | User ) { +async function existUser(user: PartialUser ) { const conditions = []; if (user?.name) { conditions.push({ name: user.name }); @@ -251,7 +247,8 @@ async function existUser(user: {[key: string]: string} | User ) { }) : null } -export async function insertUser(user: {[key: string]: string}) { +export async function insertUser(user: PartialUser ) { + console.log('------------', user) try { return await prisma.user.create({ data: user