Initial commit with the content of temp branch

This commit is contained in:
sijinhui
2024-04-29 17:19:44 +08:00
parent fc39af6dbf
commit 7611c58527
5 changed files with 13 additions and 28 deletions

View File

@@ -5,7 +5,7 @@ import CredentialsProvider from "next-auth/providers/credentials";
import {PrismaAdapter} from "@next-auth/prisma-adapter";
import prisma from "@/lib/prisma";
import { User } from "@prisma/client";
import {ADMIN_LIST, isEmail, isName} from "@/lib/auth_list";
import { isEmail, isName } from "@/lib/auth_list";
import {createTransport} from "nodemailer";
import { comparePassword, hashPassword } from "@/lib/utils";
import {getCurStartEnd} from "@/app/utils/custom";
@@ -194,17 +194,6 @@ export async function getSessionName() {
}
}
export async function VerifiedUser() {
const { name, session } = await getSessionName();
const userId = session?.user?.id
return !!(name && isName(name) && userId);
}
export async function VerifiedAdminUser() {
const { name, session } = await getSessionName();
return !!(name && ADMIN_LIST.includes(name));
}
export function validatePassword(password: string, hashPassword: string | null | undefined ): boolean | void {
if (!hashPassword) {
throw new Error("未设置密码");

View File

@@ -1,10 +1,5 @@
import {ADMIN_LIST, isName} from "@/lib/auth_list";
import { JWT } from "next-auth/jwt";
import { User } from "@prisma/client";
type CUS_JWT = JWT & {
user: User,
}
import {isName} from "@/lib/auth_list";
import { CUS_JWT } from "@/lib/auth_type";
export async function VerifiedUser(session: CUS_JWT |null) {

View File

@@ -4,12 +4,6 @@ export const DENY_LIST: string[] = [
"suibian", "某某", "张三", "李四", "啊实打实", "官方回复电话", "笑死", "观化听风", "null", "undefined",
"zhangsan",
]
export const ADMIN_LIST: string[] = [
"sijinhui", "sijinhui@qq.com",
"yuchuan", "于川",
"jujujujuju",
]
export function isEmail(input: string): boolean {
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

6
lib/auth_type.ts Normal file
View File

@@ -0,0 +1,6 @@
import { JWT } from "next-auth/jwt";
import { User } from "@prisma/client";
export type CUS_JWT = JWT & {
user: User,
}