|
|
@@ -9,11 +9,13 @@ const router = Router();
|
|
|
const authService = new AuthService();
|
|
|
|
|
|
// 获取注册配置(公开接口)
|
|
|
-router.get('/config', (req, res) => {
|
|
|
+router.get('/config', (_req, res) => {
|
|
|
+ // 环境变量优先,必须明确设置为 'true' 才开放注册
|
|
|
+ const allowRegistration = process.env.ALLOW_REGISTRATION === 'true';
|
|
|
res.json({
|
|
|
success: true,
|
|
|
data: {
|
|
|
- allowRegistration: process.env.ALLOW_REGISTRATION !== 'false',
|
|
|
+ allowRegistration,
|
|
|
},
|
|
|
});
|
|
|
});
|
|
|
@@ -54,15 +56,6 @@ router.post(
|
|
|
validateRequest,
|
|
|
],
|
|
|
asyncHandler(async (req, res) => {
|
|
|
- // 检查是否开放注册
|
|
|
- const allowRegistration = process.env.ALLOW_REGISTRATION !== 'false';
|
|
|
- if (!allowRegistration) {
|
|
|
- return res.status(403).json({
|
|
|
- success: false,
|
|
|
- message: '注册功能已关闭,请联系管理员',
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
const { username, password, email, nickname } = req.body;
|
|
|
|
|
|
const result = await authService.register({ username, password, email, nickname });
|