mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56:39 +08:00
commit
5f5b2c7299
@ -64,6 +64,7 @@ async function handle(
|
|||||||
emailVerified: item.emailVerified,
|
emailVerified: item.emailVerified,
|
||||||
createdAt: item.createdAt,
|
createdAt: item.createdAt,
|
||||||
updatedAt: item.updatedAt,
|
updatedAt: item.updatedAt,
|
||||||
|
allowToLogin: item.allowToLogin,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
notification,
|
notification,
|
||||||
Popconfirm,
|
Popconfirm,
|
||||||
|
Checkbox,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import type { GetRef, TableColumnsType } from "antd";
|
import type { GetRef, TableColumnsType } from "antd";
|
||||||
// import { headers } from 'next/headers'
|
// import { headers } from 'next/headers'
|
||||||
@ -187,6 +188,18 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
|
|||||||
dataIndex: "updatedAt",
|
dataIndex: "updatedAt",
|
||||||
render: (value) => getCurrentTime(new Date(value)),
|
render: (value) => getCurrentTime(new Date(value)),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "allowToLogin",
|
||||||
|
dataIndex: "allowToLogin",
|
||||||
|
width: 120,
|
||||||
|
render: (value) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Checkbox defaultChecked={value} disabled></Checkbox>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Action",
|
title: "Action",
|
||||||
dataIndex: "",
|
dataIndex: "",
|
||||||
@ -195,7 +208,8 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
|
|||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
{contextHolder}
|
{contextHolder}
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title="输入新密码"
|
id="user-admin-table-pop_confirm"
|
||||||
|
title="设置密码"
|
||||||
description={
|
description={
|
||||||
<>
|
<>
|
||||||
<Input.Password
|
<Input.Password
|
||||||
|
@ -95,3 +95,7 @@ input {
|
|||||||
#login-form input:-webkit-autofill {
|
#login-form input:-webkit-autofill {
|
||||||
transition: background-color 5000s ease-in-out 0s;
|
transition: background-color 5000s ease-in-out 0s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#user-admin-table-pop_confirm input:-webkit-autofill {
|
||||||
|
transition: background-color 5000s ease-in-out 0s;
|
||||||
|
}
|
||||||
|
@ -348,7 +348,11 @@ export class ClaudeApi implements LLMApi {
|
|||||||
path(path: string): string {
|
path(path: string): string {
|
||||||
const accessStore = useAccessStore.getState();
|
const accessStore = useAccessStore.getState();
|
||||||
|
|
||||||
let baseUrl: string = accessStore.anthropicUrl;
|
let baseUrl: string = "";
|
||||||
|
|
||||||
|
if (accessStore.useCustomConfig) {
|
||||||
|
baseUrl = accessStore.anthropicUrl;
|
||||||
|
}
|
||||||
|
|
||||||
// if endpoint is empty, use default endpoint
|
// if endpoint is empty, use default endpoint
|
||||||
if (baseUrl.trim().length === 0) {
|
if (baseUrl.trim().length === 0) {
|
||||||
|
@ -104,7 +104,13 @@ export class GeminiProApi implements LLMApi {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const accessStore = useAccessStore.getState();
|
const accessStore = useAccessStore.getState();
|
||||||
let baseUrl = accessStore.googleUrl;
|
|
||||||
|
let baseUrl = "";
|
||||||
|
|
||||||
|
if (accessStore.useCustomConfig) {
|
||||||
|
baseUrl = accessStore.googleUrl;
|
||||||
|
}
|
||||||
|
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
|
|
||||||
let shouldStream = !!options.config.stream;
|
let shouldStream = !!options.config.stream;
|
||||||
|
@ -61,6 +61,9 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
path(path: string, isAzure?: boolean, azureModel?: string): string {
|
path(path: string, isAzure?: boolean, azureModel?: string): string {
|
||||||
const accessStore = useAccessStore.getState();
|
const accessStore = useAccessStore.getState();
|
||||||
|
|
||||||
|
let baseUrl = "";
|
||||||
|
|
||||||
|
if (accessStore.useCustomConfig) {
|
||||||
// const isAzure = accessStore.provider === ServiceProvider.Azure;
|
// const isAzure = accessStore.provider === ServiceProvider.Azure;
|
||||||
|
|
||||||
if (isAzure && !accessStore.isValidAzure()) {
|
if (isAzure && !accessStore.isValidAzure()) {
|
||||||
@ -69,7 +72,12 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
|
if (isAzure) {
|
||||||
|
path = makeAzurePath(path, accessStore.azureApiVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
baseUrl = isAzure ? accessStore.azureUrl : accessStore.openaiUrl;
|
||||||
|
}
|
||||||
|
|
||||||
if (baseUrl.length === 0) {
|
if (baseUrl.length === 0) {
|
||||||
const isApp = !!getClientConfig()?.isApp;
|
const isApp = !!getClientConfig()?.isApp;
|
||||||
|
@ -63,26 +63,26 @@ export function createWebDavClient(store: SyncStore) {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
path(path: string, proxyUrl: string = "") {
|
path(path: string, proxyUrl: string = "") {
|
||||||
// if (!path.endsWith("/")) {
|
|
||||||
// path += "/";
|
|
||||||
// }
|
|
||||||
if (path.startsWith("/")) {
|
if (path.startsWith("/")) {
|
||||||
path = path.slice(1);
|
path = path.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxyUrl.length > 0 && !proxyUrl.endsWith("/")) {
|
if (proxyUrl.endsWith("/")) {
|
||||||
proxyUrl += "/";
|
proxyUrl = proxyUrl.slice(0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let url;
|
let url;
|
||||||
if (proxyUrl.length > 0 || proxyUrl === "/") {
|
const pathPrefix = "/api/webdav/";
|
||||||
let u = new URL(proxyUrl + "api/webdav/" + path);
|
|
||||||
|
try {
|
||||||
|
let u = new URL(proxyUrl + pathPrefix + path);
|
||||||
// add query params
|
// add query params
|
||||||
u.searchParams.append("endpoint", config.endpoint);
|
u.searchParams.append("endpoint", config.endpoint);
|
||||||
url = u.toString();
|
url = u.toString();
|
||||||
} else {
|
} catch (e) {
|
||||||
url = "/api/upstash/" + path + "?endpoint=" + config.endpoint;
|
url = pathPrefix + path + "?endpoint=" + config.endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -29,6 +29,9 @@ export const authOptions: NextAuthOptions = {
|
|||||||
image: profile.avatar_url,
|
image: profile.avatar_url,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
httpOptions: {
|
||||||
|
timeout: 50000,
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
EmailProvider({
|
EmailProvider({
|
||||||
server: {
|
server: {
|
||||||
@ -152,11 +155,12 @@ export const authOptions: NextAuthOptions = {
|
|||||||
// console.log('555555555,', session, token)
|
// console.log('555555555,', session, token)
|
||||||
return session;
|
return session;
|
||||||
},
|
},
|
||||||
// 过滤不存在的用户,目前没用
|
// 过滤不存在的用户
|
||||||
async signIn({ user, account, profile, email, credentials }) {
|
async signIn({ user, account, profile, email, credentials }) {
|
||||||
const existingUser = await existUser(user as User);
|
const existingUser = await existUser(user as User);
|
||||||
console.log('---', user, 'account', account, 'email', email, 'exist', existingUser)
|
console.log('---', user, 'account', account, 'email', email, 'exist', existingUser)
|
||||||
return !!existingUser;
|
// 顺便过滤掉不允许登录的用户
|
||||||
|
return !!existingUser && existingUser.allowToLogin;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -24,6 +24,7 @@ model User {
|
|||||||
password String?
|
password String?
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
|
allowToLogin Boolean @default(true)
|
||||||
accounts Account[]
|
accounts Account[]
|
||||||
sessions Session[]
|
sessions Session[]
|
||||||
// sites Site[]
|
// sites Site[]
|
||||||
|
Loading…
Reference in New Issue
Block a user