Skip to content

Commit

Permalink
revert to 285d808 (undo button commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
solderq35 committed Apr 3, 2024
1 parent 50dbb4d commit f953427
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
File renamed without changes.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,15 @@ Info below subject to change

### Login Bypass

- Press the "Test Login" button on the SignIn page
- NOTE: Current implementation does not have persistent storage for the test user, if you reload or restart the server you need to press the "Test Login" button again (assuming you wanted to stay signed in as test user)
- `yarn test`
- Bypass login for testing purposes, will log you in as a dummy user "John Doe"
- If you logged out of app, reload / restart app to automatically log back in as dummy user
- Optional arguments:
- `--tunnel`
- For WiFi tunneling as described above
- `--ios` or `--android`
- For running app on iOS or Android emulator
- Note that arguments can be combined, e.g. `yarn test --android --tunnel`

### Formatting Script

Expand Down
25 changes: 0 additions & 25 deletions app/(auth)/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
View,
} from "react-native";
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
import { currentAuthContext } from "~/context/Auth";
import { auth } from "~/firebaseConfig";

const BUTTON_WIDTH = 150;
Expand All @@ -25,7 +24,6 @@ const INPUT_WIDTH = 200;
export default function SignIn() {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const { setCurrentUserId } = currentAuthContext();

async function handleSignIn() {
try {
Expand All @@ -41,20 +39,6 @@ export default function SignIn() {
}
}

async function handleTestSignIn() {
try {
// Check the env var exists just in case.
// I put the test uid in an .env file to make it easier to change if we ever need to call it elsewhere, otherwise
// this could be hardcoded.
if (process.env.EXPO_PUBLIC_TEST_UID) {
setCurrentUserId(process.env.EXPO_PUBLIC_TEST_UID);
}
} catch (e) {
alert(e);
console.log(e);
}
}

async function handleForgotPassword() {
try {
if (email === "") {
Expand Down Expand Up @@ -126,15 +110,6 @@ export default function SignIn() {
>
<Text style={styles.buttonText}>Login</Text>
</Pressable>

<Pressable
style={styles.button}
onPress={handleTestSignIn}
backgroundColor={"#F24E1E"}
>
<Text style={styles.buttonText}>Test Login</Text>
</Pressable>

<Pressable style={styles.button} backgroundColor={"#F24E1E"}>
<Link asChild href={"/signup"}>
<Text style={styles.buttonText}>Sign Up</Text>
Expand Down
15 changes: 12 additions & 3 deletions context/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,18 @@ export const AuthProvider = ({ children }) => {
//if this code is not in here, it'll run for infinite times
onAuthStateChanged(auth, (currentUserId) => {
console.log("user changed");
console.log(currentUserId);
if (currentUserId) {
setCurrentUserId(currentUserId.uid ?? "Error (uid)");

// test user login (yarn test)
// If you sign out, reload app to sign back in as test user
if (process.env.EXPO_PUBLIC_TEST_UID) {
setCurrentUserId(process.env.EXPO_PUBLIC_TEST_UID);
}

// regular user login
else {
if (currentUserId) {
setCurrentUserId(currentUserId.uid ?? "Error (uid)");
}
}
});
}, []);
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"main": "expo-router/entry",
"scripts": {
"start": "expo start",
"test": "cross-env NODE_ENV=test expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
Expand All @@ -18,6 +19,7 @@
"@react-native-async-storage/async-storage": "^1.22.3",
"@tanstack/react-query": "^5.24.1",
"babel-plugin-root-import": "^6.6.0",
"cross-env": "^7.0.3",
"d3-scale": "^4.0.2",
"d3-shape": "^3.2.0",
"expo": "~49.0.15",
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4228,6 +4228,13 @@ cosmiconfig@^5.0.5, cosmiconfig@^5.1.0:
js-yaml "^3.13.1"
parse-json "^4.0.0"

cross-env@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
dependencies:
cross-spawn "^7.0.1"

cross-fetch@^3.1.5:
version "3.1.8"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82"
Expand All @@ -4246,7 +4253,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"

cross-spawn@^7.0.0, cross-spawn@^7.0.3:
cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
Expand Down

0 comments on commit f953427

Please sign in to comment.