secure privkey

This commit is contained in:
Ren Amamiya
2023-07-09 16:55:25 +07:00
parent a5c2ec080a
commit cba94ab99e
20 changed files with 1011 additions and 499 deletions

View File

@@ -1,14 +1,21 @@
import { ReactNode } from 'react';
import { Navigate } from 'react-router-dom';
import { useStronghold } from '@stores/stronghold';
import { useAccount } from '@utils/hooks/useAccount';
export function Protected({ children }: { children: ReactNode }) {
const password = useStronghold((state) => state.password);
const { status, account } = useAccount();
if (status === 'success' && !account) {
return <Navigate to="/auth/welcome" replace />;
}
if (status === 'success' && account && !password) {
return <Navigate to="/auth/unlock" replace />;
}
return children;
}