From 00a26892b527c1739eeeb4a4871727ebe17e14ee Mon Sep 17 00:00:00 2001 From: rca Date: Tue, 9 Jul 2024 04:21:59 +0900 Subject: [PATCH] =?UTF-8?q?=E6=9A=AB=E5=AE=9A=E3=81=A7childId=E3=82=92?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3=E6=99=82=E3=81=AB=E8=BF=94?= =?UTF-8?q?=E3=81=99=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routers/child/authRouter.ts | 4 ++-- src/services/child/authService.ts | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/routers/child/authRouter.ts b/src/routers/child/authRouter.ts index 4b3dd84..cb6adce 100644 --- a/src/routers/child/authRouter.ts +++ b/src/routers/child/authRouter.ts @@ -9,8 +9,8 @@ router.post('/login', (req: Request, res: Response) => { if (!loginCode) { return res.status(400).json({ message: 'ログインコードが指定されていません' }); } - login(loginCode).then((token) => { - res.status(200).json({ accessToken: token }); + login(loginCode).then(resp => { + res.status(200).json(resp); }).catch((err) => { res.status(500).json({ message: 'ログインに失敗しました', detail: err }); }); diff --git a/src/services/child/authService.ts b/src/services/child/authService.ts index e61e680..c06bd09 100644 --- a/src/services/child/authService.ts +++ b/src/services/child/authService.ts @@ -1,7 +1,7 @@ import prisma from '@src/prisma'; import { issueTokenByChildId } from '@src/utils/tokenUtils'; -async function login(loginCode: string): Promise { +async function login(loginCode: string): Promise { // Workaround const childId: string | null = await prisma.activeLoginCode.findUnique({ where: { code: parseInt(loginCode) @@ -20,7 +20,10 @@ async function login(loginCode: string): Promise { code: parseInt(loginCode) } }); - return await issueTokenByChildId(childId); + return { + accessToken: issueTokenByChildId(childId), + childId: childId + }; } export { login };