mirror of
https://github.com/JetSprow/J-Board-Lite.git
synced 2026-05-01 01:14:10 +05:30
feat: enhance subscription risk review workflow
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { getServerSession } from "next-auth";
|
||||
import { authOptions } from "./auth";
|
||||
import { getActiveSubscriptionRiskRestriction } from "@/services/subscription-risk-review";
|
||||
|
||||
export async function requireAdmin() {
|
||||
const session = await getServerSession(authOptions);
|
||||
@@ -9,10 +10,18 @@ export async function requireAdmin() {
|
||||
return session;
|
||||
}
|
||||
|
||||
export async function requireAuth() {
|
||||
export async function requireAuth(options: { allowDuringRiskRestriction?: boolean } = {}) {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session) {
|
||||
throw new Error("未登录");
|
||||
}
|
||||
|
||||
if (session.user.role !== "ADMIN" && !options.allowDuringRiskRestriction) {
|
||||
const restriction = await getActiveSubscriptionRiskRestriction(session.user.id);
|
||||
if (restriction) {
|
||||
throw new Error("账户存在未处理的订阅风控限制,请先新建工单联系客服");
|
||||
}
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user