diff --git a/App.tsx b/App.tsx
index 392327a..04c1986 100644
--- a/App.tsx
+++ b/App.tsx
@@ -1,43 +1,14 @@
-import React, { useEffect } from "react";
-import { ClientProvider, useAuthHeader } from "./src/graphql/client";
+import React from "react";
+import { AuthProvider } from "./src/context";
+import { ClientProvider } from "./src/graphql/client";
import AppNavigator from "./src/navigation/app-navigator";
-import { DEV_USER_ID } from "@env";
-import AsyncStorage from "@react-native-async-storage/async-storage";
-import Loading from "./src/lib/loading";
-
-// TODO: move to different file?
-const SetAuthHeaderBasedOnEnv = () => {
- const { setAuthHeader } = useAuthHeader();
-
- useEffect(() => {
- const setAuthAsync = async () => {
- if (DEV_USER_ID) {
- console.log("Setting fake authorization user to: ", DEV_USER_ID);
- setAuthHeader({ key: "user_id", value: DEV_USER_ID });
- } else {
- // Fetch token for authenticated users in production
- const token = await AsyncStorage.getItem("token"); // get from not firebase auth ASYNC
- if (token) {
- console.log("Setting firebase auth token");
- setAuthHeader({ key: "Authorization", value: `Bearer ${token}` });
- }
- }
- };
-
- setAuthAsync();
- }, [setAuthHeader]);
-
- return null;
-};
-
const App: React.FC = () => {
return (
-
-
+
-
+
);
};
diff --git a/package.json b/package.json
index 5e547a6..9c6208f 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,6 @@
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "NODE_ENV=development && expo start",
- "start:test": "NODE_ENV=development && expo start",
"start:android": "expo start --android",
"start:ios": "expo start --ios",
"android": "expo run:android",
@@ -12,7 +11,7 @@
"android:test": "node ./start.js test",
"ios": "expo run:ios",
"ios:dev": "NODE_ENV=development expo run:ios",
- "ios:prod": "NODE_ENV=production expo run:ios",
+ "ios:prod": "NODE_ENV=test expo run:ios",
"web": "expo start --web",
"lint": "eslint . --ext .js,.ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix",
diff --git a/src/auth/firebase-auth.tsx b/src/auth/firebase-auth.tsx
index 732b171..35e37c4 100644
--- a/src/auth/firebase-auth.tsx
+++ b/src/auth/firebase-auth.tsx
@@ -1,4 +1,3 @@
-import AsyncStorage from "@react-native-async-storage/async-storage";
import auth, { FirebaseAuthTypes } from "@react-native-firebase/auth";
import { Alert } from "react-native";
@@ -47,7 +46,6 @@ export const getCurrentUserToken = async (): Promise => {
return null;
};
-export const handleSignOut = async (): Promise => {
- await AsyncStorage.removeItem("token");
- await auth().signOut();
+export const handleSignOut = (): Promise => {
+ return auth().signOut();
};
diff --git a/src/component/buttons/sign-out.tsx b/src/component/buttons/sign-out.tsx
index 3c65bca..ea4e2b7 100644
--- a/src/component/buttons/sign-out.tsx
+++ b/src/component/buttons/sign-out.tsx
@@ -1,18 +1,16 @@
import React from "react";
import { Button } from "react-native";
-import { handleSignOut } from "../../auth";
+import { useAuth } from "../../context";
import { useAuthHeader } from "../../graphql/client";
export default function SignOutButton(): React.JSX.Element {
+ const { logOut } = useAuth();
const { setAuthHeader } = useAuthHeader();
- return (
-