WuYongJie ba98bf22cc feat: 添加许可证系统、Agent部署模块和Harbor镜像管理
- 新增许可证服务器 (license-server/)
- 新增 Agent 部署模块 (flnxi-agent/)
- 添加许可证验证和激活页面
- 添加 Harbor 镜像同步脚本
- 更新素材系统支持许可证验证
2025-12-15 21:19:46 +08:00

47 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { NextRequest, NextResponse } from 'next/server';
import { verifyAdmin } from '@/lib/auth';
export async function POST(request: NextRequest) {
try {
const { username, password } = await request.json();
if (!username || !password) {
return NextResponse.json(
{ success: false, error: '请输入用户名和密码' },
{ status: 400 }
);
}
const result = await verifyAdmin(username, password);
if (result.success && result.token) {
const response = NextResponse.json({ success: true });
// 根据请求协议决定是否设置 Secure(支持 HTTP 部署)
const isSecure = request.headers.get('x-forwarded-proto') === 'https' ||
request.url.startsWith('https://');
response.cookies.set('admin_token', result.token, {
httpOnly: true,
secure: isSecure,
sameSite: 'lax',
maxAge: 24 * 60 * 60, // 24小时
path: '/',
});
return response;
}
return NextResponse.json(
{ success: false, error: result.error },
{ status: 401 }
);
} catch (error) {
console.error('登录失败:', error);
return NextResponse.json(
{ success: false, error: '服务器错误' },
{ status: 500 }
);
}
}