From c4e009dd732fb7a3604c72b93f835bf32a886df4 Mon Sep 17 00:00:00 2001
From: KaichiManabe <154493010+KaichiManabe@users.noreply.github.com>
Date: Sun, 12 May 2024 13:01:51 +0900
Subject: [PATCH 1/9] =?UTF-8?q?merge=E3=81=97=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/src/app/(tabs)/profile.tsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/front/src/app/(tabs)/profile.tsx b/front/src/app/(tabs)/profile.tsx
index eaa51329..694c25e3 100644
--- a/front/src/app/(tabs)/profile.tsx
+++ b/front/src/app/(tabs)/profile.tsx
@@ -13,6 +13,7 @@ const image = { uri: "https://legacy.reactjs.org/logo-og.png" };
const Profile = (): JSX.Element => {
// sample
console.log(useAuthContext());
+ const user = useAuthContext();
return (
@@ -21,7 +22,7 @@ const Profile = (): JSX.Element => {
Name:
- Michael
+ {user?.displayName}
Sex:
From 042ebcb61130c8362d7de1da9c18818870b3acc3 Mon Sep 17 00:00:00 2001
From: KaichiManabe <154493010+KaichiManabe@users.noreply.github.com>
Date: Sun, 26 May 2024 13:00:33 +0900
Subject: [PATCH 2/9] =?UTF-8?q?profile.txt=E3=81=A7=E3=80=81=E8=87=AA?=
=?UTF-8?q?=E5=88=86=E3=81=AE=E5=90=8D=E5=89=8D=E3=81=A8userID=E3=82=92?=
=?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?=
=?UTF-8?q?=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/src/app/(tabs)/profile.tsx | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/front/src/app/(tabs)/profile.tsx b/front/src/app/(tabs)/profile.tsx
index 694c25e3..51939585 100644
--- a/front/src/app/(tabs)/profile.tsx
+++ b/front/src/app/(tabs)/profile.tsx
@@ -14,6 +14,7 @@ const Profile = (): JSX.Element => {
// sample
console.log(useAuthContext());
const user = useAuthContext();
+
return (
@@ -22,11 +23,11 @@ const Profile = (): JSX.Element => {
Name:
- {user?.displayName}
+ {user?.name}
- Sex:
- Male
+ ID:
+ {user?.id}
Sample:
From fcee9935d3a4f40fd835f62832a8d7a9336223a7 Mon Sep 17 00:00:00 2001
From: KaichiManabe <154493010+KaichiManabe@users.noreply.github.com>
Date: Sun, 26 May 2024 13:03:26 +0900
Subject: [PATCH 3/9] =?UTF-8?q?fetch=E3=81=AE=E6=99=82=E3=81=AE=E3=82=A8?=
=?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD?=
=?UTF-8?q?=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/src/app/(tabs)/followRequestList.tsx | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/front/src/app/(tabs)/followRequestList.tsx b/front/src/app/(tabs)/followRequestList.tsx
index ccda4a01..b9343409 100644
--- a/front/src/app/(tabs)/followRequestList.tsx
+++ b/front/src/app/(tabs)/followRequestList.tsx
@@ -25,6 +25,17 @@ fetch("http://localhost:3000/requests/" + currentUserId.toString(), {
.then((data) => {
console.log("success: fetching matchRequests");
matchRequests = data;
+ })
+ .catch((error) => {
+ // Handle Errors here.
+ // const errorCode = error.code;
+ // const errorMessage = error.message;
+ // The email of the user's account used.
+ // const email = error.customData.email;
+ // The AuthCredential type that was used.
+ // const credential = GoogleAuthProvider.credentialFromError(error);
+ // ...
+ console.error(error);
});
const List = (): JSX.Element => {
From 944d2afc8eee880f881c7680a12c1d9c7b5dbf0b Mon Sep 17 00:00:00 2001
From: KaichiManabe <154493010+KaichiManabe@users.noreply.github.com>
Date: Sun, 26 May 2024 13:04:04 +0900
Subject: [PATCH 4/9] =?UTF-8?q?=E3=81=84=E3=82=89=E3=81=AA=E3=81=84?=
=?UTF-8?q?=E9=83=A8=E5=88=86=E5=89=8A=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/src/app/(tabs)/profile.tsx | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/front/src/app/(tabs)/profile.tsx b/front/src/app/(tabs)/profile.tsx
index 51939585..c906ae6f 100644
--- a/front/src/app/(tabs)/profile.tsx
+++ b/front/src/app/(tabs)/profile.tsx
@@ -49,18 +49,7 @@ const Profile = (): JSX.Element => {
Sample:
Sample Text
-
- Sample:
- Sample Text
-
-
- Sample:
- Sample Text
-
-
- Sample:
- Sample Text
-
+
);
From c05df499e2b069ca121218c105419bfe06c1522e Mon Sep 17 00:00:00 2001
From: KaichiManabe <154493010+KaichiManabe@users.noreply.github.com>
Date: Sun, 26 May 2024 14:41:16 +0900
Subject: [PATCH 5/9] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A2=E3=82=A6?=
=?UTF-8?q?=E3=83=88=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E5=AE=9F=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/src/app/(tabs)/login.tsx | 22 +++++++++++++++++++---
front/src/app/(tabs)/profile.tsx | 1 -
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/front/src/app/(tabs)/login.tsx b/front/src/app/(tabs)/login.tsx
index 702348dd..eee2489d 100644
--- a/front/src/app/(tabs)/login.tsx
+++ b/front/src/app/(tabs)/login.tsx
@@ -1,11 +1,11 @@
-import { GoogleAuthProvider, signInWithPopup } from "firebase/auth";
+import { GoogleAuthProvider, signInWithPopup ,signOut} from "firebase/auth";
import { View, Text, StyleSheet } from "react-native";
import Button from "../../components/Button";
import { auth } from "../../firebase/firebaseconfig";
const provider = new GoogleAuthProvider();
-const handlePress = (): void => {
+const signIn = (): void => {
signInWithPopup(auth, provider)
.then((result) => {
// This gives you a Google Access Token. You can use it to access the Google API.
@@ -31,6 +31,15 @@ const handlePress = (): void => {
console.error(error);
});
};
+const signOutUser = (): void => {
+ signOut(auth)
+ .then(() => {
+ console.log('サインアウトしました');
+ })
+ .catch((error) => {
+ console.error('サインアウトエラー: ', error);
+ });
+};
const LogIn = (): JSX.Element => {
return (
@@ -40,7 +49,13 @@ const LogIn = (): JSX.Element => {
);
From 7a2895ba3b9910bbff35dfaf0dc8db04ca9bfd09 Mon Sep 17 00:00:00 2001
From: KaichiManabe <154493010+KaichiManabe@users.noreply.github.com>
Date: Sun, 26 May 2024 17:42:58 +0900
Subject: [PATCH 6/9] =?UTF-8?q?login.tsx=E3=81=AE=E5=A0=B4=E6=89=80?=
=?UTF-8?q?=E3=82=92=E7=A7=BB=E5=8B=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/src/app/{(tabs) => }/login.tsx | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)
rename front/src/app/{(tabs) => }/login.tsx (80%)
diff --git a/front/src/app/(tabs)/login.tsx b/front/src/app/login.tsx
similarity index 80%
rename from front/src/app/(tabs)/login.tsx
rename to front/src/app/login.tsx
index eee2489d..da17162b 100644
--- a/front/src/app/(tabs)/login.tsx
+++ b/front/src/app/login.tsx
@@ -1,8 +1,8 @@
-import { GoogleAuthProvider, signInWithPopup ,signOut} from "firebase/auth";
+import { GoogleAuthProvider, signInWithPopup } from "firebase/auth";
import { View, Text, StyleSheet } from "react-native";
-import Button from "../../components/Button";
-import { auth } from "../../firebase/firebaseconfig";
+import Button from "../components/Button";
+import { auth } from "../firebase/firebaseconfig";
const provider = new GoogleAuthProvider();
const signIn = (): void => {
@@ -31,15 +31,6 @@ const signIn = (): void => {
console.error(error);
});
};
-const signOutUser = (): void => {
- signOut(auth)
- .then(() => {
- console.log('サインアウトしました');
- })
- .catch((error) => {
- console.error('サインアウトエラー: ', error);
- });
-};
const LogIn = (): JSX.Element => {
return (
@@ -52,12 +43,6 @@ const LogIn = (): JSX.Element => {
signIn();
}}
/>
- {
- signOutUser();
- }}
- />
東京大学のGoogleアカウントを用いてログインしてください
@@ -68,7 +53,6 @@ const LogIn = (): JSX.Element => {
);
};
-
const styles = StyleSheet.create({
container: {
flex: 1,
From 644f8f8d67c706df7381daf3c17e8bb82576361b Mon Sep 17 00:00:00 2001
From: KaichiManabe <154493010+KaichiManabe@users.noreply.github.com>
Date: Sun, 26 May 2024 19:03:19 +0900
Subject: [PATCH 7/9] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?=
=?UTF-8?q?=E3=80=81=E3=83=AD=E3=82=B0=E3=82=A2=E3=82=A6=E3=83=88=E3=81=AE?=
=?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=BF=E3=82=A4=E3=83=97=E5=AE=9F?=
=?UTF-8?q?=E8=A3=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/src/app/(tabs)/profile.tsx | 6 ++---
front/src/app/login.tsx | 8 ++++++
front/src/components/LogOutButton.tsx | 35 +++++++++++++++++----------
3 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/front/src/app/(tabs)/profile.tsx b/front/src/app/(tabs)/profile.tsx
index 2298a2fc..93dfa455 100644
--- a/front/src/app/(tabs)/profile.tsx
+++ b/front/src/app/(tabs)/profile.tsx
@@ -6,6 +6,7 @@ import {
ImageBackground,
} from "react-native";
+import LogOutButton from "../../components/LogOutButton";
import { useAuthContext } from "../../provider/AuthProvider";
const image = { uri: "https://legacy.reactjs.org/logo-og.png" };
@@ -45,10 +46,7 @@ const Profile = (): JSX.Element => {
Sample:
Sample Text
-
- Sample:
- Sample Text
-
+
);
diff --git a/front/src/app/login.tsx b/front/src/app/login.tsx
index da17162b..e87fc009 100644
--- a/front/src/app/login.tsx
+++ b/front/src/app/login.tsx
@@ -1,8 +1,10 @@
+import { useRouter } from "expo-router";
import { GoogleAuthProvider, signInWithPopup } from "firebase/auth";
import { View, Text, StyleSheet } from "react-native";
import Button from "../components/Button";
import { auth } from "../firebase/firebaseconfig";
+
const provider = new GoogleAuthProvider();
const signIn = (): void => {
@@ -17,6 +19,7 @@ const signIn = (): void => {
// IdP data available using getAdditionalUserInfo(result)
// ...
console.log(user.metadata);
+ console.log("ログインに成功しました");
}
})
.catch((error) => {
@@ -29,10 +32,13 @@ const signIn = (): void => {
// const credential = GoogleAuthProvider.credentialFromError(error);
// ...
console.error(error);
+ console.log("ログインに失敗しました");
});
};
const LogIn = (): JSX.Element => {
+ const router = useRouter();
+
return (
@@ -41,8 +47,10 @@ const LogIn = (): JSX.Element => {
label="Log In"
onPress={() => {
signIn();
+ router.push("/");
}}
/>
+
東京大学のGoogleアカウントを用いてログインしてください
diff --git a/front/src/components/LogOutButton.tsx b/front/src/components/LogOutButton.tsx
index 5927f513..76a58a19 100644
--- a/front/src/components/LogOutButton.tsx
+++ b/front/src/components/LogOutButton.tsx
@@ -1,22 +1,31 @@
-import { Text, TouchableOpacity, StyleSheet } from "react-native";
+import { useRouter } from "expo-router";
+import { signOut } from "firebase/auth";
+import { TouchableOpacity } from "react-native";
+
+import { auth } from "../firebase/firebaseconfig";
const LogOutButton = (): JSX.Element => {
+ const router = useRouter();
return (
-
- ログアウト
+ {
+ signOutUser();
+ router.push("/login");
+ }}
+ >
+ ログアウト
);
};
-const styles = StyleSheet.create({
- logOutButtonLabel: {
- color: "rgba(255, 255, 255, 0.7)",
- fontSize: 16,
- lineHeight: 32,
- fontWeight: "bold",
- paddingVertical: 8,
- paddingHorizontal: 24,
- },
-});
+const signOutUser = (): void => {
+ signOut(auth)
+ .then(() => {
+ console.log("サインアウトしました");
+ })
+ .catch((error) => {
+ console.error("サインアウトエラー: ", error);
+ });
+};
export default LogOutButton;
From 05a5ac8d0eb4810b53ef74f9071cd7897f2550bb Mon Sep 17 00:00:00 2001
From: KaichiManabe <154493010+KaichiManabe@users.noreply.github.com>
Date: Tue, 28 May 2024 18:52:56 +0900
Subject: [PATCH 8/9] =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=83=B3=E3=82=A4?=
=?UTF-8?q?=E3=83=B3=E3=83=9C=E3=82=BF=E3=83=B3=E3=82=92=E9=9D=9E=E5=90=8C?=
=?UTF-8?q?=E6=9C=9F=E5=87=A6=E7=90=86=E3=81=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/src/app/login.tsx | 55 ++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/front/src/app/login.tsx b/front/src/app/login.tsx
index e87fc009..1be188c8 100644
--- a/front/src/app/login.tsx
+++ b/front/src/app/login.tsx
@@ -7,33 +7,32 @@ import { auth } from "../firebase/firebaseconfig";
const provider = new GoogleAuthProvider();
-const signIn = (): void => {
- signInWithPopup(auth, provider)
- .then((result) => {
- // This gives you a Google Access Token. You can use it to access the Google API.
- const credential = GoogleAuthProvider.credentialFromResult(result);
- if (credential) {
- // const token = credential.accessToken;
- // The signed-in user info.
- const user = result.user;
- // IdP data available using getAdditionalUserInfo(result)
- // ...
- console.log(user.metadata);
- console.log("ログインに成功しました");
- }
- })
- .catch((error) => {
- // Handle Errors here.
- // const errorCode = error.code;
- // const errorMessage = error.message;
- // The email of the user's account used.
- // const email = error.customData.email;
- // The AuthCredential type that was used.
- // const credential = GoogleAuthProvider.credentialFromError(error);
+const signIn = async (): Promise => {
+ try {
+ const result = await signInWithPopup(auth, provider);
+ // This gives you a Google Access Token. You can use it to access the Google API.
+ const credential = GoogleAuthProvider.credentialFromResult(result);
+ if (credential) {
+ // const token = credential.accessToken;
+ // The signed-in user info.
+ const user = result.user;
+ // IdP data available using getAdditionalUserInfo(result)
// ...
- console.error(error);
- console.log("ログインに失敗しました");
- });
+ console.log(user.metadata);
+ console.log("ログインに成功しました");
+ }
+ } catch (error) {
+ // Handle Errors here.
+ // const errorCode = error.code;
+ // const errorMessage = error.message;
+ // The email of the user's account used.
+ // const email = error.customData.email;
+ // The AuthCredential type that was used.
+ // const credential = GoogleAuthProvider.credentialFromError(error);
+ // ...
+ console.error(error);
+ console.log("ログインに失敗しました");
+ }
};
const LogIn = (): JSX.Element => {
@@ -45,8 +44,8 @@ const LogIn = (): JSX.Element => {
Log In
{
- signIn();
+ onPress={async () => {
+ await signIn();
router.push("/");
}}
/>
From a67b96ff5d488a370a71df45a9affebd159cf485 Mon Sep 17 00:00:00 2001
From: KaichiManabe <154493010+KaichiManabe@users.noreply.github.com>
Date: Tue, 28 May 2024 19:48:09 +0900
Subject: [PATCH 9/9] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?=
=?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?=
=?UTF-8?q?=E3=82=89=E3=80=81=E3=83=AA=E3=83=80=E3=82=A4=E3=83=AC=E3=82=AF?=
=?UTF-8?q?=E3=83=88=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/package-lock.json | 44 +++++++++++++++++++--------
front/package.json | 4 ++-
front/src/components/LogOutButton.tsx | 2 +-
front/src/provider/AuthProvider.tsx | 20 +++++++++---
4 files changed, 51 insertions(+), 19 deletions(-)
diff --git a/front/package-lock.json b/front/package-lock.json
index f9478b84..ff1e819a 100644
--- a/front/package-lock.json
+++ b/front/package-lock.json
@@ -8,6 +8,8 @@
"name": "front",
"version": "1.0.0",
"dependencies": {
+ "@react-navigation/native": "^6.1.17",
+ "@react-navigation/stack": "^6.3.29",
"expo": "~50.0.11",
"expo-constants": "~15.4.5",
"expo-linking": "~6.2.2",
@@ -15,8 +17,8 @@
"expo-status-bar": "~1.11.1",
"firebase": "^10.11.0",
"react": "18.2.0",
- "react-native-dotenv": "^3.4.11",
"react-native": "^0.73.6",
+ "react-native-dotenv": "^3.4.11",
"react-native-gesture-handler": "~2.14.0",
"react-native-safe-area-context": "4.8.2",
"react-native-screens": "~3.29.0",
@@ -6752,16 +6754,16 @@
}
},
"node_modules/@react-navigation/core": {
- "version": "6.4.13",
- "resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-6.4.13.tgz",
- "integrity": "sha512-RBUpNG11SEYfvvWefJPxz8Xu/feWuPxln7ddRSY92aKs7u6fj/Z694Jun76Gmmw/RIHW6xcu3PH2v3Wm8nbumg==",
+ "version": "6.4.16",
+ "resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-6.4.16.tgz",
+ "integrity": "sha512-UDTJBsHxnzgFETR3ZxhctP+RWr4SkyeZpbhpkQoIGOuwSCkt1SE0qjU48/u6r6w6XlX8OqVudn1Ab0QFXTHxuQ==",
"dependencies": {
"@react-navigation/routers": "^6.1.9",
"escape-string-regexp": "^4.0.0",
"nanoid": "^3.1.23",
"query-string": "^7.1.3",
"react-is": "^16.13.0",
- "use-latest-callback": "^0.1.7"
+ "use-latest-callback": "^0.1.9"
},
"peerDependencies": {
"react": "*"
@@ -6784,9 +6786,9 @@
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"node_modules/@react-navigation/elements": {
- "version": "1.3.26",
- "resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.3.26.tgz",
- "integrity": "sha512-9rSY7MD6etU3M3j/OYUvtg4eBqABlkS39iJwwQheE89pSa9QyvXbJSsz/bUBEjFWwsOYxTVzj27bc7ulrDVWgw==",
+ "version": "1.3.30",
+ "resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.3.30.tgz",
+ "integrity": "sha512-plhc8UvCZs0UkV+sI+3bisIyn78wz9O/BiWZXpounu72k/R/Sj5PuZYFJ1fi6psvriUveMCGh4LeZckAZu2qiQ==",
"peerDependencies": {
"@react-navigation/native": "^6.0.0",
"react": "*",
@@ -6795,11 +6797,11 @@
}
},
"node_modules/@react-navigation/native": {
- "version": "6.1.14",
- "resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-6.1.14.tgz",
- "integrity": "sha512-nCrVi4cHXx6VnXV8fj+lLb8zjLt1LZkpxudhfV/i1KstgaoGzh9FgFDIvbWONGE8f403FIsYUnZxKHvN7asp1w==",
+ "version": "6.1.17",
+ "resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-6.1.17.tgz",
+ "integrity": "sha512-mer3OvfwWOHoUSMJyLa4vnBH3zpFmCwuzrBPlw7feXklurr/ZDiLjLxUScOot6jLRMz/67GyilEYMmP99LL0RQ==",
"dependencies": {
- "@react-navigation/core": "^6.4.13",
+ "@react-navigation/core": "^6.4.16",
"escape-string-regexp": "^4.0.0",
"fast-deep-equal": "^3.1.3",
"nanoid": "^3.1.23"
@@ -6844,6 +6846,24 @@
"nanoid": "^3.1.23"
}
},
+ "node_modules/@react-navigation/stack": {
+ "version": "6.3.29",
+ "resolved": "https://registry.npmjs.org/@react-navigation/stack/-/stack-6.3.29.tgz",
+ "integrity": "sha512-tzlGkoRgB6P7vgw7rHuWo3TL7Gzu6xh5LMf+zSdCuEiKp/qASzxYfnTEr9tOLbVs/gf+qeukEDheCSAJKVpBXw==",
+ "dependencies": {
+ "@react-navigation/elements": "^1.3.30",
+ "color": "^4.2.3",
+ "warn-once": "^0.1.0"
+ },
+ "peerDependencies": {
+ "@react-navigation/native": "^6.0.0",
+ "react": "*",
+ "react-native": "*",
+ "react-native-gesture-handler": ">= 1.0.0",
+ "react-native-safe-area-context": ">= 3.0.0",
+ "react-native-screens": ">= 3.0.0"
+ }
+ },
"node_modules/@remix-run/node": {
"version": "1.19.3",
"resolved": "https://registry.npmjs.org/@remix-run/node/-/node-1.19.3.tgz",
diff --git a/front/package.json b/front/package.json
index 805af19f..b0dbc148 100644
--- a/front/package.json
+++ b/front/package.json
@@ -11,6 +11,8 @@
"build": "expo export --platform web"
},
"dependencies": {
+ "@react-navigation/native": "^6.1.17",
+ "@react-navigation/stack": "^6.3.29",
"expo": "~50.0.11",
"expo-constants": "~15.4.5",
"expo-linking": "~6.2.2",
@@ -18,8 +20,8 @@
"expo-status-bar": "~1.11.1",
"firebase": "^10.11.0",
"react": "18.2.0",
- "react-native-dotenv": "^3.4.11",
"react-native": "^0.73.6",
+ "react-native-dotenv": "^3.4.11",
"react-native-gesture-handler": "~2.14.0",
"react-native-safe-area-context": "4.8.2",
"react-native-screens": "~3.29.0",
diff --git a/front/src/components/LogOutButton.tsx b/front/src/components/LogOutButton.tsx
index 76a58a19..45a0fd28 100644
--- a/front/src/components/LogOutButton.tsx
+++ b/front/src/components/LogOutButton.tsx
@@ -10,7 +10,7 @@ const LogOutButton = (): JSX.Element => {
{
signOutUser();
- router.push("/login");
+ router.replace("/login");
}}
>
ログアウト
diff --git a/front/src/provider/AuthProvider.tsx b/front/src/provider/AuthProvider.tsx
index 1142a569..f33b97cc 100644
--- a/front/src/provider/AuthProvider.tsx
+++ b/front/src/provider/AuthProvider.tsx
@@ -1,5 +1,6 @@
+import { useRouter } from "expo-router";
import { getAuth, onAuthStateChanged } from "firebase/auth";
-import { createContext, useContext, useEffect, useState } from "react";
+import React, { createContext, useContext, useEffect, useState } from "react";
interface User {
id: number;
@@ -16,6 +17,8 @@ export default function AuthProvider({
children: React.ReactNode;
}) {
const [user, setUser] = useState(undefined);
+ const router = useRouter();
+
async function getUserData(uid: string): Promise {
try {
const response = await fetch(`http://localhost:3000/users/${uid}`);
@@ -30,13 +33,20 @@ export default function AuthProvider({
try {
const auth = getAuth();
return onAuthStateChanged(auth, (firebaseUser) => {
- getUserData(firebaseUser!.uid).then((user) => setUser(user));
+ if (firebaseUser) {
+ getUserData(firebaseUser.uid).then((user) => setUser(user));
+ } else {
+ setUser(null);
+ router.replace("/login"); // ログインされていない場合にリダイレクト
+ console.log("リダイレクトされました");
+ }
});
- } catch (error) {
+ } catch {
setUser(null);
- throw error;
+ router.replace("/login"); // エラー発生時にリダイレクト
+ console.log("エラーです");
}
- }, []);
+ }, [router]);
return {children};
}