From adf500af38156667d2aae46af4e3856d616e7bce Mon Sep 17 00:00:00 2001 From: Tom Beckenham <34339192+tombeckenham@users.noreply.github.com> Date: Mon, 9 Dec 2024 10:21:55 +1100 Subject: [PATCH] Now includes ability to set DEV_PASSWORD Closes #259 --- src/ui/views/Unlock/index.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ui/views/Unlock/index.tsx b/src/ui/views/Unlock/index.tsx index 9e266ea3..7ac3e4eb 100644 --- a/src/ui/views/Unlock/index.tsx +++ b/src/ui/views/Unlock/index.tsx @@ -43,6 +43,15 @@ const UsernameError: React.FC = () => ( ); +if (process.env.NODE_ENV !== 'development') { + if (!!process.env.DEV_PASSWORD) { + throw new Error('DEV_PASSWORD should only be set in development environment'); + } +} + +const DEFAULT_PASSWORD = + process.env.NODE_ENV === 'development' ? process.env.DEV_PASSWORD || '' : ''; + const Unlock = () => { const wallet = useWallet(); const classes = useStyles(); @@ -50,7 +59,7 @@ const Unlock = () => { const inputEl = useRef(null); // const { t } = useTranslation(); const [showError, setShowError] = useState(false); - const [password, setPassword] = useState(''); + const [password, setPassword] = useState(DEFAULT_PASSWORD); const [resetPop, setResetPop] = useState(false); useEffect(() => {