修复权限判断问题
This commit is contained in:
@@ -45,12 +45,10 @@ export async function POST(request: NextRequest) {
|
|||||||
// 获取配置与存储
|
// 获取配置与存储
|
||||||
const adminConfig = await getConfig();
|
const adminConfig = await getConfig();
|
||||||
|
|
||||||
// 权限与身份校验
|
// 权限与身份校验 - 使用v2用户系统
|
||||||
if (username !== process.env.USERNAME) {
|
if (username !== process.env.USERNAME) {
|
||||||
const userEntry = adminConfig.UserConfig.Users.find(
|
const userInfo = await db.getUserInfoV2(username);
|
||||||
(u) => u.username === username
|
if (!userInfo || userInfo.role !== 'admin' || userInfo.banned) {
|
||||||
);
|
|
||||||
if (!userEntry || userEntry.role !== 'admin' || userEntry.banned) {
|
|
||||||
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,13 @@ export const runtime = 'nodejs';
|
|||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
// 权限检查
|
// 权限检查 - 使用v2用户系统
|
||||||
const authInfo = getAuthInfoFromCookie(request);
|
const authInfo = getAuthInfoFromCookie(request);
|
||||||
const username = authInfo?.username;
|
const username = authInfo?.username;
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
if (username !== process.env.USERNAME) {
|
if (username !== process.env.USERNAME) {
|
||||||
// 管理员
|
const userInfo = await db.getUserInfoV2(username || '');
|
||||||
const user = config.UserConfig.Users.find(
|
if (!userInfo || userInfo.role !== 'admin' || userInfo.banned) {
|
||||||
(u) => u.username === username
|
|
||||||
);
|
|
||||||
if (!user || user.role !== 'admin' || user.banned) {
|
|
||||||
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,13 @@ export const runtime = 'nodejs';
|
|||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
try {
|
try {
|
||||||
// 权限检查
|
// 权限检查 - 使用v2用户系统
|
||||||
const authInfo = getAuthInfoFromCookie(request);
|
const authInfo = getAuthInfoFromCookie(request);
|
||||||
const username = authInfo?.username;
|
const username = authInfo?.username;
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
if (username !== process.env.USERNAME) {
|
if (username !== process.env.USERNAME) {
|
||||||
// 管理员
|
const userInfo = await db.getUserInfoV2(username || '');
|
||||||
const user = config.UserConfig.Users.find(
|
if (!userInfo || userInfo.role !== 'admin' || userInfo.banned) {
|
||||||
(u) => u.username === username
|
|
||||||
);
|
|
||||||
if (!user || user.role !== 'admin' || user.banned) {
|
|
||||||
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,12 +37,10 @@ export async function POST(request: NextRequest) {
|
|||||||
// 获取配置
|
// 获取配置
|
||||||
const adminConfig = await getConfig();
|
const adminConfig = await getConfig();
|
||||||
|
|
||||||
// 权限检查
|
// 权限检查 - 使用v2用户系统
|
||||||
if (username !== process.env.USERNAME) {
|
if (username !== process.env.USERNAME) {
|
||||||
const userEntry = adminConfig.UserConfig.Users.find(
|
const userInfo = await db.getUserInfoV2(username);
|
||||||
(u) => u.username === username
|
if (!userInfo || userInfo.role !== 'admin' || userInfo.banned) {
|
||||||
);
|
|
||||||
if (!userEntry || userEntry.role !== 'admin' || userEntry.banned) {
|
|
||||||
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,13 +148,10 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
const adminConfig = await getConfig();
|
const adminConfig = await getConfig();
|
||||||
|
|
||||||
// 权限校验
|
// 权限校验 - 使用v2用户系统
|
||||||
if (username !== process.env.USERNAME) {
|
if (username !== process.env.USERNAME) {
|
||||||
// 管理员
|
const userInfo = await db.getUserInfoV2(username);
|
||||||
const user = adminConfig.UserConfig.Users.find(
|
if (!userInfo || userInfo.role !== 'admin' || userInfo.banned) {
|
||||||
(u) => u.username === username
|
|
||||||
);
|
|
||||||
if (!user || user.role !== 'admin' || user.banned) {
|
|
||||||
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,13 +92,10 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
const adminConfig = await getConfig();
|
const adminConfig = await getConfig();
|
||||||
|
|
||||||
// 权限校验
|
// 权限校验 - 使用v2用户系统
|
||||||
if (username !== process.env.USERNAME) {
|
if (username !== process.env.USERNAME) {
|
||||||
// 管理员
|
const userInfo = await db.getUserInfoV2(username);
|
||||||
const user = adminConfig.UserConfig.Users.find(
|
if (!userInfo || userInfo.role !== 'admin' || userInfo.banned) {
|
||||||
(u) => u.username === username
|
|
||||||
);
|
|
||||||
if (!user || user.role !== 'admin' || user.banned) {
|
|
||||||
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
return NextResponse.json({ error: '权限不足' }, { status: 401 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,14 +36,6 @@ export async function GET(request: NextRequest) {
|
|||||||
const operatorInfo = await db.getUserInfoV2(authInfo.username);
|
const operatorInfo = await db.getUserInfoV2(authInfo.username);
|
||||||
if (operatorInfo) {
|
if (operatorInfo) {
|
||||||
operatorRole = operatorInfo.role;
|
operatorRole = operatorInfo.role;
|
||||||
} else {
|
|
||||||
// 回退到配置中查找
|
|
||||||
const userEntry = adminConfig.UserConfig.Users.find(
|
|
||||||
(u) => u.username === authInfo.username
|
|
||||||
);
|
|
||||||
if (userEntry) {
|
|
||||||
operatorRole = userEntry.role;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ export async function GET(request: NextRequest) {
|
|||||||
return {
|
return {
|
||||||
name: live.name,
|
name: live.name,
|
||||||
type: 0,
|
type: 0,
|
||||||
|
playerType: 1,
|
||||||
url: live.url,
|
url: live.url,
|
||||||
epg: live.epg || '',
|
epg: live.epg || '',
|
||||||
logo: '',
|
logo: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user