From c162e0f066ab6d1b96b63f7165d2fc57762edd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 19 Jun 2024 16:06:01 +0900 Subject: [PATCH] =?UTF-8?q?login=E3=82=A8=E3=83=B3=E3=83=89=E3=83=9D?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routers/child/authRouter.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/routers/child/authRouter.ts b/src/routers/child/authRouter.ts index de95bc0..f671bb4 100644 --- a/src/routers/child/authRouter.ts +++ b/src/routers/child/authRouter.ts @@ -1,7 +1,17 @@ import { Router, Request, Response } from 'express'; +import { login } from '@src/services/child/authService'; const router = Router(); // login router.post('/login', (req: Request, res: Response) => { - + const code: number = req.body.code; + if (!code) { + return res.status(400).json({ message: 'ログインコードが指定されていません' }); + } + login(code).then((token) => { + res.status(200).json({ accessToken: token }); + }).catch((err) => { + res.status(500).json({ message: 'ログインに失敗しました', detail: err }); + }); +});