生产环境修正
This commit is contained in:
@@ -234,6 +234,37 @@ router.post('/refresh', async (req: Request, res: Response): Promise<void> => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Get Captcha
|
||||
* GET /api/auth/captcha
|
||||
*/
|
||||
router.get('/captcha', async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
// 生成简单的数学验证码
|
||||
const num1 = Math.floor(Math.random() * 10) + 1;
|
||||
const num2 = Math.floor(Math.random() * 10) + 1;
|
||||
const answer = num1 + num2;
|
||||
|
||||
// 生成验证码ID
|
||||
const captchaId = Math.random().toString(36).substring(2, 15);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: {
|
||||
captchaId,
|
||||
question: `${num1} + ${num2} = ?`,
|
||||
answer // 在实际生产环境中,这应该存储在服务器端而不是返回给客户端
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取验证码失败:', error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: '服务器内部错误'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* User Logout
|
||||
* POST /api/auth/logout
|
||||
|
||||
Reference in New Issue
Block a user