返回提交历史
Modified
src/services/loginService.ts
+15
-1
XFEstudio/SpaceNinjaServer
chore: optimise getAccountIdForRequest (#814)
73df848f
代码差异
1 个文件
+15
-1
@@ -71,7 +71,21 @@ export const getAccountForRequest = async (req: Request): Promise<TAccountDocume
71
71
};
72
72
73
73
export const getAccountIdForRequest = async (req: Request): Promise<string> => {
74
return (await getAccountForRequest(req))._id.toString();
74
if (!req.query.accountId) {
75
throw new Error("Request is missing accountId parameter");
76
}
77
if (!req.query.nonce || parseInt(req.query.nonce as string) === 0) {
78
throw new Error("Request is missing nonce parameter");
79
}
80
if (
81
!(await Account.exists({
82
_id: req.query.accountId,
83
Nonce: req.query.nonce
84
}))
85
) {
86
throw new Error("Invalid accountId-nonce pair");
87
}
88
return req.query.accountId as string;
75
89
};
76
90
77
91
export const isAdministrator = (account: TAccountDocument): boolean => {