mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56:39 +08:00
Merge branch 'main' into dev
This commit is contained in:
commit
ee2e66fc93
@ -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第三代模型最强版",
|
||||
|
@ -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 };
|
||||
}
|
||||
|
@ -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,
|
||||
|
15
lib/auth.ts
15
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<User>;
|
||||
|
||||
|
||||
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")) {
|
||||
// 如果不存在,则创建
|
||||
user['allowToLogin'] = !!await getSetting("allowNewUser");
|
||||
existingUser = await insertUser(user);
|
||||
} else {
|
||||
// 如果不存在,则报错
|
||||
throw new Error("未知用户")
|
||||
}
|
||||
}
|
||||
// 有密码就校验密码,没有就直接返回用户
|
||||
(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
|
||||
|
Loading…
Reference in New Issue
Block a user