diff --git a/.eslintrc.js b/.eslintrc.js
index c278541..bf8aa8d 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -30,7 +30,7 @@ module.exports = {
rules: {
// Best Practices
eqeqeq: ["error", "always"], // Enforce '===' instead of '=='
- curly: "error", // Require curly braces for all control statements
+ curly: ["error", "multi-line", "consistent"], // Require curly braces for all control statements
"no-unused-vars": "warn", // Warn about variables that are declared but not used
// React Specific
diff --git a/App.tsx b/App.tsx
index 5d69b5f..04c1986 100644
--- a/App.tsx
+++ b/App.tsx
@@ -1,40 +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";
-
-// 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 b9b2cbd..fa7eb0b 100644
--- a/package.json
+++ b/package.json
@@ -11,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",
@@ -25,7 +25,6 @@
},
"dependencies": {
"@apollo/client": "^3.8.8",
- "@react-native-async-storage/async-storage": "^1.21.0",
"@react-native-camera-roll/camera-roll": "^7.4.0",
"@react-native-firebase/app": "^18.8.0",
"@react-native-firebase/auth": "^18.8.0",
diff --git a/src/auth/firebase-auth.tsx b/src/auth/firebase-auth.tsx
index 732b171..d545816 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";
@@ -39,6 +38,8 @@ export const onAuthStateChanged = (
return auth().onAuthStateChanged(callback);
};
+export const currentUser = () => auth().currentUser;
+
export const getCurrentUserToken = async (): Promise => {
const user = auth().currentUser;
if (user) {
@@ -47,7 +48,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/auth/index.ts b/src/auth/index.ts
index 89b62ac..e766cfb 100644
--- a/src/auth/index.ts
+++ b/src/auth/index.ts
@@ -1,6 +1,6 @@
import {
confirmCode,
- getCurrentUserToken,
+ currentUser,
handleSignInWithPhoneNumber,
handleSignOut,
onAuthStateChanged,
@@ -8,7 +8,7 @@ import {
export {
confirmCode,
- getCurrentUserToken,
+ currentUser,
handleSignInWithPhoneNumber,
handleSignOut,
onAuthStateChanged,
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 (
-