暫定でchildIdをログイン時に返すように

This commit is contained in:
rca 2024-07-09 04:21:59 +09:00
parent 80461ecb17
commit 00a26892b5
2 changed files with 7 additions and 4 deletions

View File

@ -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 });
});

View File

@ -1,7 +1,7 @@
import prisma from '@src/prisma';
import { issueTokenByChildId } from '@src/utils/tokenUtils';
async function login(loginCode: string): Promise<string | null> {
async function login(loginCode: string): Promise<any> { // Workaround
const childId: string | null = await prisma.activeLoginCode.findUnique({
where: {
code: parseInt(loginCode)
@ -20,7 +20,10 @@ async function login(loginCode: string): Promise<string | null> {
code: parseInt(loginCode)
}
});
return await issueTokenByChildId(childId);
return {
accessToken: issueTokenByChildId(childId),
childId: childId
};
}
export { login };