From 3439f38e34debd511786c25815696a4706aef817 Mon Sep 17 00:00:00 2001 From: TkymHrt <23.h.takayama.nutfes@gmail.com> Date: Sat, 16 Nov 2024 20:33:05 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=20=E3=82=B5=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=82=A2=E3=83=83=E3=83=97=E5=BE=8C=E3=81=AB=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=81=95=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/lib/signInAndUp.ts | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/app/src/lib/signInAndUp.ts b/app/src/lib/signInAndUp.ts index 56b7dcd..6428008 100644 --- a/app/src/lib/signInAndUp.ts +++ b/app/src/lib/signInAndUp.ts @@ -14,18 +14,23 @@ export const signInOrUp = async (firebaseUser: FirebaseUser) => { }, }); - const userData = await res.json(); - - const user: DBUser = { ...userData }; + if (res.status === 200) { + const userData = await res.json(); + const user: DBUser = { ...userData }; - if (userData) { - storeStorageUser(user); - if (!userData.experiencePoint) { - await createExp(userData.id); + if (userData) { + storeStorageUser(user); + if (!userData.experiencePoint) { + await createExp(userData.id); + } + toRoot(); } - toRoot(); - } else { + } else if (res.status === 404) { await signUp(firebaseUser); + // サインアップ後にユーザー情報を取得してログイン処理を行う + await signInOrUp(firebaseUser); + } else { + console.error(`Unexpected status code: ${res.status}`); } } catch (error) { console.error("エラーが発生しました:", error); @@ -42,14 +47,11 @@ const signUp = async (user: User) => { body: JSON.stringify(user), }); - const resUser = await res.json(); - - if (resUser) { - storeStorageUser(resUser); - toRoot(); - } else { - throw new Error("ユーザー登録に失敗"); + if (res.status === 200) { + // ユーザー登録が成功した場合は何もせず戻る + return; } + throw new Error("ユーザー登録に失敗"); } catch (error) { console.error("エラーが発生しました:", error); } From 86d64b08b29e419317ad5780db63923e6fefbb5f Mon Sep 17 00:00:00 2001 From: TkymHrt <23.h.takayama.nutfes@gmail.com> Date: Sat, 16 Nov 2024 21:10:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[fix]=20isActive=E3=82=92false=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/app/camera/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/app/camera/page.tsx b/app/src/app/camera/page.tsx index 37ff42e..df48474 100644 --- a/app/src/app/camera/page.tsx +++ b/app/src/app/camera/page.tsx @@ -88,7 +88,7 @@ const CameraApp = () => { todayAssignment | undefined >(); const [assignments, setAssignments] = useState([]); - const [isActive, setIsActive] = useState(true); + const [isActive, setIsActive] = useState(false); const [isPointDialogOpen, _] = usePointDialog(); const openDialog = useOpenPointDialog(); const [loginUser, setLoginUser] = useState();