From 596aea78903d2e5c40bb164f5436b62226dac9c7 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 19 Dec 2024 01:33:30 +0100 Subject: [PATCH] Add getAccountForRequest --- src/services/loginService.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/services/loginService.ts b/src/services/loginService.ts index 3ddb7982..36d4d57e 100644 --- a/src/services/loginService.ts +++ b/src/services/loginService.ts @@ -44,7 +44,7 @@ export const createPersonalRooms = async (accountId: Types.ObjectId, shipId: Typ await personalRooms.save(); }; -export const getAccountIdForRequest = async (req: Request): Promise => { +export const getAccountForRequest = async (req: Request) => { if (!req.query.accountId) { throw new Error("Request is missing accountId parameter"); } @@ -61,5 +61,9 @@ export const getAccountIdForRequest = async (req: Request): Promise => { if (!account) { throw new Error("Invalid accountId-nonce pair"); } - return account._id.toString(); + return account; +}; + +export const getAccountIdForRequest = async (req: Request): Promise => { + return (await getAccountForRequest(req))._id.toString(); };