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