mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-02 16:16:39 +08:00
commit
834e1438c2
9
app/app/(admin)/components/users-table.modules.scss
Normal file
9
app/app/(admin)/components/users-table.modules.scss
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
input {
|
||||||
|
text-align: left !important
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.ant-input {
|
||||||
|
text-align: left !important
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import "./users-table.modules.scss";
|
||||||
import React, { Dispatch, SetStateAction, useEffect, useState } from "react";
|
import React, { Dispatch, SetStateAction, useEffect, useState } from "react";
|
||||||
import { User } from "@prisma/client";
|
import { User } from "@prisma/client";
|
||||||
import {
|
import {
|
||||||
@ -50,7 +51,7 @@ function UserTableSearchInput({ users, setUsers, setLoading }: UserInterface) {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const fetchUsers = async () => {
|
const fetchUsers = async () => {
|
||||||
try {
|
try {
|
||||||
const url = new URL("/api/admin/users/", window.location.href);
|
const url = new URL("/api/admin/users", window.location.href);
|
||||||
url.searchParams.append("search", searchText);
|
url.searchParams.append("search", searchText);
|
||||||
console.log(url, "url");
|
console.log(url, "url");
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
@ -95,7 +96,7 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
|
|||||||
const confirmPassword = async (id: string) => {
|
const confirmPassword = async (id: string) => {
|
||||||
console.log("-----", newPassword, id);
|
console.log("-----", newPassword, id);
|
||||||
try {
|
try {
|
||||||
fetch(`/api/admin/users/${id}/`, {
|
fetch(`/api/admin/users/${id}`, {
|
||||||
method: "put",
|
method: "put",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
@ -9,10 +9,6 @@
|
|||||||
margin-right: auto
|
margin-right: auto
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
|
||||||
text-align: left !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.signin hr {
|
.signin hr {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border: 0;
|
border: 0;
|
||||||
|
20
lib/auth.ts
20
lib/auth.ts
@ -4,6 +4,7 @@ import EmailProvider from "next-auth/providers/email";
|
|||||||
import CredentialsProvider from "next-auth/providers/credentials";
|
import CredentialsProvider from "next-auth/providers/credentials";
|
||||||
import {PrismaAdapter} from "@next-auth/prisma-adapter";
|
import {PrismaAdapter} from "@next-auth/prisma-adapter";
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import { User } from "@prisma/client";
|
||||||
import {ADMIN_LIST, isEmail, isName} from "@/lib/auth_list";
|
import {ADMIN_LIST, isEmail, isName} from "@/lib/auth_list";
|
||||||
import {createTransport} from "nodemailer";
|
import {createTransport} from "nodemailer";
|
||||||
|
|
||||||
@ -140,6 +141,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 }) {
|
||||||
|
// const existingUser = await existUser(user as User);
|
||||||
|
// console.log('---', user, 'account', account, 'email', email, 'exist', existingUser)
|
||||||
|
// return !!existingUser;
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -233,9 +240,7 @@ export async function VerifiedAdminUser() {
|
|||||||
// };
|
// };
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
async function existUser(user: {[key: string]: string} | User ) {
|
||||||
export async function insertUser(user: {[key: string]: string}) {
|
|
||||||
try {
|
|
||||||
const conditions = [];
|
const conditions = [];
|
||||||
if (user?.name) {
|
if (user?.name) {
|
||||||
conditions.push({ name: user.name });
|
conditions.push({ name: user.name });
|
||||||
@ -243,11 +248,16 @@ export async function insertUser(user: {[key: string]: string}) {
|
|||||||
if (user?.email) {
|
if (user?.email) {
|
||||||
conditions.push({ email: user.email });
|
conditions.push({ email: user.email });
|
||||||
}
|
}
|
||||||
const existingUser = conditions.length? await prisma.user.findFirst({
|
return conditions.length ? await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
AND: conditions,
|
AND: conditions,
|
||||||
},
|
},
|
||||||
}) : null;
|
}) : null
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function insertUser(user: {[key: string]: string}) {
|
||||||
|
try {
|
||||||
|
const existingUser = await existUser(user);
|
||||||
// console.log('[LOG]', existingUser, user, '=======')
|
// console.log('[LOG]', existingUser, user, '=======')
|
||||||
if (!existingUser) {
|
if (!existingUser) {
|
||||||
return await prisma.user.create({
|
return await prisma.user.create({
|
||||||
|
Loading…
Reference in New Issue
Block a user