From dccbda1e3750141fd044ef4cba3c05654a5d13f3 Mon Sep 17 00:00:00 2001 From: Skylar Saveland Date: Wed, 4 Jul 2018 16:27:22 -0700 Subject: [PATCH] closes #6 bypass auth in development --- .env | 2 ++ .gitignore | 2 ++ README.md | 7 +++++++ applications/ZcashOSX/.babelrc | 2 +- applications/ZcashOSX/package.json | 1 + core/state/reducers.js | 11 ++++++----- yarn.lock | 16 ++++++++++++++++ 7 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..3395e6c --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +REACT_APP_ZCASH_USERNAME='' +REACT_APP_ZCASH_PASSWORD='' diff --git a/.gitignore b/.gitignore index eb03e3e..e068d31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules *.log +.env + diff --git a/README.md b/README.md index 5efa585..90b0c31 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,10 @@ app will update live! Sweet! cd applications/ZcashOSX yarn macos ``` + +To bypass the auth screen while developing, +set `REACT_APP_ZCASH_USERNAME` and `REACT_APP_ZCASH_PASSWORD` +in the `.env` file in the root directory. +Note: to toggle this with the application running, +you might need to change and save `core/state/reducers.js` +to provoke babel to retranspile that file. diff --git a/applications/ZcashOSX/.babelrc b/applications/ZcashOSX/.babelrc index 4991c30..2704241 100644 --- a/applications/ZcashOSX/.babelrc +++ b/applications/ZcashOSX/.babelrc @@ -1,5 +1,5 @@ { - "presets": ["react-native"], + "presets": ["react-native", "react-native-dotenv"], "plugins": [ ["module-resolver", { "alias": { diff --git a/applications/ZcashOSX/package.json b/applications/ZcashOSX/package.json index aa4950d..6c3f8b2 100644 --- a/applications/ZcashOSX/package.json +++ b/applications/ZcashOSX/package.json @@ -26,6 +26,7 @@ "crna-make-symlinks-for-yarn-workspaces": "^1.0.1", "jest": "23.1.0", "metro-bundler-config-yarn-workspaces": "^1.0.3", + "react-native-dotenv": "^0.1.1", "react-test-renderer": "16.2.0" }, "jest": { diff --git a/core/state/reducers.js b/core/state/reducers.js index f881f29..8ce4108 100644 --- a/core/state/reducers.js +++ b/core/state/reducers.js @@ -1,12 +1,13 @@ import { combineReducers } from 'redux' +import { + REACT_APP_ZCASH_USERNAME, + REACT_APP_ZCASH_PASSWORD, +} from 'react-native-dotenv' - -// TODO: inject configuration for development let default_auth = { - username: 'z', - password: 'a', + username: REACT_APP_ZCASH_USERNAME, + password: REACT_APP_ZCASH_PASSWORD, } -default_auth = {} const auth = (state = default_auth, action) => { switch (action.type) { diff --git a/yarn.lock b/yarn.lock index 26342df..0154596 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1133,6 +1133,12 @@ babel-plugin-check-es2015-constants@^6.5.0, babel-plugin-check-es2015-constants@ dependencies: babel-runtime "^6.22.0" +babel-plugin-dotenv@0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/babel-plugin-dotenv/-/babel-plugin-dotenv-0.1.1.tgz#9c8faea67a7c034fe7e94099187ab2e7573400bc" + dependencies: + dotenv "^2.0.0" + babel-plugin-external-helpers@^6.18.0, babel-plugin-external-helpers@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-external-helpers/-/babel-plugin-external-helpers-6.22.0.tgz#2285f48b02bd5dede85175caf8c62e86adccefa1" @@ -2590,6 +2596,10 @@ dot-case@^1.1.0: dependencies: sentence-case "^1.1.2" +dotenv@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-2.0.0.tgz#bd759c357aaa70365e01c96b7b0bec08a6e0d949" + duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" @@ -6470,6 +6480,12 @@ react-native-dismiss-keyboard@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/react-native-dismiss-keyboard/-/react-native-dismiss-keyboard-1.0.0.tgz#32886242b3f2317e121f3aeb9b0a585e2b879b49" +react-native-dotenv@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/react-native-dotenv/-/react-native-dotenv-0.1.1.tgz#95a943dbaba24ddf50e95bd861e5a0c4ab03a38d" + dependencies: + babel-plugin-dotenv "0.1.1" + react-native-drawer-layout-polyfill@^1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/react-native-drawer-layout-polyfill/-/react-native-drawer-layout-polyfill-1.3.2.tgz#192c84d7a5a6b8a6d2be2c7daa5e4164518d0cc7"