Skip to content

Commit

Permalink
Merge pull request #563 from Kodylow/fix-single-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow authored Oct 18, 2024
2 parents 6dad54a + c520cb6 commit 7af7332
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
30 changes: 28 additions & 2 deletions apps/router/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,55 @@ import { ColorModeScript } from '@chakra-ui/react';

import { i18nProvider, sha256Hash } from '@fedimint/utils';
import { languages } from './languages';
import { AppContextProvider } from './context/AppContext';
import { APP_ACTION_TYPE, AppContextProvider } from './context/AppContext';
import { HomePage } from './home/HomePage';
import { GuardianContextProvider } from './context/guardian/GuardianContext';
import { GatewayContextProvider } from './context/gateway/GatewayContext';
import { Wrapper } from './components/Wrapper';
import { useAppContext } from './context/hooks';

i18nProvider(languages);

const App = () => {
const { dispatch } = useAppContext();
const [redirectPath, setRedirectPath] = useState<string | null>(null);

useEffect(() => {
const calculateRedirectPath = async () => {
if (process.env.REACT_APP_FM_CONFIG_API) {
try {
const hash = await sha256Hash(process.env.REACT_APP_FM_CONFIG_API);
dispatch({
type: APP_ACTION_TYPE.ADD_GUARDIAN,
payload: {
id: hash,
guardian: {
config: {
id: hash,
baseUrl: process.env.REACT_APP_FM_CONFIG_API,
},
},
},
});
setRedirectPath(`/guardian/${hash}`);
} catch (e) {
console.error(e);
}
} else if (process.env.REACT_APP_FM_GATEWAY_API) {
try {
const hash = await sha256Hash(process.env.REACT_APP_FM_GATEWAY_API);
dispatch({
type: APP_ACTION_TYPE.ADD_GATEWAY,
payload: {
id: hash,
gateway: {
config: {
id: hash,
baseUrl: process.env.REACT_APP_FM_GATEWAY_API,
},
},
},
});
setRedirectPath(`/gateway/${hash}`);
} catch (e) {
console.error(e);
Expand All @@ -46,7 +72,7 @@ const App = () => {
};

calculateRedirectPath();
}, []);
}, [dispatch]);

return (
<Router>
Expand Down
2 changes: 1 addition & 1 deletion mprocs-nix-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ procs:
BROWSER: none
GATEWAY_TYPE: ldk
guardian-ui-1:
shell: bash --init-file scripts/mprocs-nix-guardian-manual.sh
shell: bash --init-file scripts/mprocs-nix-guardian.sh
stop: SIGKILL
env:
PORT: '3000'
Expand Down

0 comments on commit 7af7332

Please sign in to comment.