diff --git a/app/api/admin/users/[[...path]]/route.ts b/app/api/admin/users/[[...path]]/route.ts index 4a53239f0..b206c595c 100644 --- a/app/api/admin/users/[[...path]]/route.ts +++ b/app/api/admin/users/[[...path]]/route.ts @@ -64,6 +64,7 @@ async function handle( emailVerified: item.emailVerified, createdAt: item.createdAt, updatedAt: item.updatedAt, + allowToLogin: item.allowToLogin, }; }), }); diff --git a/app/app/(admin)/components/users-table.tsx b/app/app/(admin)/components/users-table.tsx index 203185294..f6226899e 100644 --- a/app/app/(admin)/components/users-table.tsx +++ b/app/app/(admin)/components/users-table.tsx @@ -10,6 +10,7 @@ import { Button, notification, Popconfirm, + Checkbox, } from "antd"; import type { GetRef, TableColumnsType } from "antd"; // import { headers } from 'next/headers' @@ -187,6 +188,18 @@ function UsersTable({ users, setUsers, loading }: UserInterface) { dataIndex: "updatedAt", render: (value) => getCurrentTime(new Date(value)), }, + { + title: "allowToLogin", + dataIndex: "allowToLogin", + width: 120, + render: (value) => { + return ( +
+ +
+ ); + }, + }, { title: "Action", dataIndex: "", @@ -195,7 +208,8 @@ function UsersTable({ users, setUsers, loading }: UserInterface) { {contextHolder} 0 && !proxyUrl.endsWith("/")) { - proxyUrl += "/"; + if (proxyUrl.endsWith("/")) { + proxyUrl = proxyUrl.slice(0, -1); } let url; - if (proxyUrl.length > 0 || proxyUrl === "/") { - let u = new URL(proxyUrl + "api/webdav/" + path); + const pathPrefix = "/api/webdav/"; + + try { + let u = new URL(proxyUrl + pathPrefix + path); // add query params u.searchParams.append("endpoint", config.endpoint); url = u.toString(); - } else { - url = "/api/upstash/" + path + "?endpoint=" + config.endpoint; + } catch (e) { + url = pathPrefix + path + "?endpoint=" + config.endpoint; } + return url; }, }; diff --git a/lib/auth.ts b/lib/auth.ts index 2c884c102..503a3c032 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -29,6 +29,9 @@ export const authOptions: NextAuthOptions = { image: profile.avatar_url, }; }, + httpOptions: { + timeout: 50000, + } }), EmailProvider({ server: { @@ -152,11 +155,12 @@ export const authOptions: NextAuthOptions = { // console.log('555555555,', session, token) return session; }, - // 过滤不存在的用户,目前没用 + // 过滤不存在的用户 async signIn({ user, account, profile, email, credentials }) { const existingUser = await existUser(user as User); console.log('---', user, 'account', account, 'email', email, 'exist', existingUser) - return !!existingUser; + // 顺便过滤掉不允许登录的用户 + return !!existingUser && existingUser.allowToLogin; } }, }; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 59f94bb03..e5b40d003 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -24,6 +24,7 @@ model User { password String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + allowToLogin Boolean @default(true) accounts Account[] sessions Session[] // sites Site[]