mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-02 08:06:38 +08:00
禁止管理员外用户使用某些模型
This commit is contained in:
parent
7603b21cbc
commit
9bab4b736f
@ -138,7 +138,7 @@ export const useAppConfig = createPersistStore(
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: StoreKey.Config,
|
name: StoreKey.Config,
|
||||||
version: 3.95,
|
version: 3.96,
|
||||||
migrate(persistedState, version) {
|
migrate(persistedState, version) {
|
||||||
const state = persistedState as ChatConfig;
|
const state = persistedState as ChatConfig;
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ export const useAppConfig = createPersistStore(
|
|||||||
// return { ...DEFAULT_CONFIG };
|
// return { ...DEFAULT_CONFIG };
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (version < 3.95) {
|
if (version < 3.96) {
|
||||||
state.modelConfig = DEFAULT_CONFIG.modelConfig;
|
state.modelConfig = DEFAULT_CONFIG.modelConfig;
|
||||||
// state.modelConfig.template =
|
// state.modelConfig.template =
|
||||||
// state.modelConfig.template !== DEFAULT_INPUT_TEMPLATE
|
// state.modelConfig.template !== DEFAULT_INPUT_TEMPLATE
|
||||||
|
@ -7,7 +7,7 @@ export function useAllModels() {
|
|||||||
const accessStore = useAccessStore();
|
const accessStore = useAccessStore();
|
||||||
const configStore = useAppConfig();
|
const configStore = useAppConfig();
|
||||||
const { data: session, status } = useSession();
|
const { data: session, status } = useSession();
|
||||||
console.log("-sssssssssss", session, status);
|
|
||||||
const models = useMemo(() => {
|
const models = useMemo(() => {
|
||||||
return collectModelsWithDefaultModel(
|
return collectModelsWithDefaultModel(
|
||||||
configStore.models,
|
configStore.models,
|
||||||
@ -22,5 +22,10 @@ export function useAllModels() {
|
|||||||
configStore.dontUseModel,
|
configStore.dontUseModel,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
|
if (status === "authenticated" && !session?.user?.isAdmin) {
|
||||||
|
// 过滤非管理员用户可使用的模型
|
||||||
|
return models.filter((m) => !m.name.endsWith("-all"));
|
||||||
|
}
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
@ -171,6 +171,8 @@ export const authOptions: NextAuthOptions = {
|
|||||||
username: token?.user?.username || token?.user?.gh_username,
|
username: token?.user?.username || token?.user?.gh_username,
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
hasPassword: !!token?.user?.password,
|
hasPassword: !!token?.user?.password,
|
||||||
|
// @ts-expect-error
|
||||||
|
isAdmin: token?.user?.isAdmin,
|
||||||
};
|
};
|
||||||
// console.log('555555555,', session, token)
|
// console.log('555555555,', session, token)
|
||||||
return session;
|
return session;
|
||||||
|
Loading…
Reference in New Issue
Block a user