给所有请求都加上jwt,隐藏生成jwt的secret(放到.env中),隐藏app-secret(放在pm2运行配置文件中,后续直接读取环境配置即可)

This commit is contained in:
2025-10-17 15:28:22 +08:00
parent 9ec6d30573
commit 59706b70d0
70 changed files with 2279 additions and 688 deletions
+6 -4
View File
@@ -87,13 +87,14 @@ async function safeGetJWT(jwtToken?: string): Promise<string> {
* @param userId 用户ID
* @returns 是否是发起人
*/
export async function findIsProposer(taskId: string | number, userId: number | undefined): Promise<boolean> {
export async function findIsProposer(taskId: string | number, userId: number | undefined, frontendJWT?: string): Promise<boolean> {
// 通过postgrest的get请求去cross_examination_tasks表中进行查找assignee_id是否等于userId
const response = await postgrestGet(`cross_examination_tasks`, {
select: 'assigner_id',
filter: {
id: `eq.${taskId}`
}
},
token: frontendJWT
});
if (response.error) {
console.error('获取任务数据失败:', response.error);
@@ -366,7 +367,8 @@ export async function performOpinionAction(
* @returns 完成评查结果
*/
export async function confirmReviewResults(
documentId: string | number
documentId: string | number,
frontendJWT?: string
): Promise<{data?: unknown, error?: string, status?: number}> {
try {
// 通过postgrest的post请求去documents表中进行查找id等于documentId的数据,更新documents表的audit_status为1
@@ -374,7 +376,7 @@ export async function confirmReviewResults(
audit_status: 1
}, {
id: documentId
});
}, frontendJWT);
if(response.error) {
return {
error: response.error,
+5 -4
View File
@@ -482,7 +482,7 @@ export async function getTaskDocuments(taskId: number, page: number = 1, pageSiz
* @param auditStatus 审核状态
* @returns 更新结果
*/
export async function updateDocumentAuditStatus(id: string, auditStatus: number): Promise<{
export async function updateDocumentAuditStatus(id: string, auditStatus: number, frontendJWT?: string): Promise<{
success?: boolean;
error?: string;
status?: number;
@@ -491,13 +491,14 @@ export async function updateDocumentAuditStatus(id: string, auditStatus: number)
if (!id) {
return { error: '文件ID不能为空', status: 400 };
}
const response = await postgrestPut<TaskDocument, Partial<TaskDocument>>(
'documents',
{ audit_status: auditStatus },
{
{
id: parseInt(id)
}
},
frontendJWT
);
if (response.error) {