Do not render password change if authenticating

This commit is contained in:
dominik-zeglen 2020-01-20 16:42:23 +01:00
parent 3fbaaf0783
commit f3ef7455ab
2 changed files with 12 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import LoginView from "./views/Login";
import NewPassword from "./views/NewPassword";
import ResetPassword from "./views/ResetPassword";
import ResetPasswordSuccess from "./views/ResetPasswordSuccess";
import LoginLoading from "./components/LoginLoading";
interface UserContext {
login: (username: string, password: string) => void;
@ -30,12 +31,20 @@ export const UserContext = React.createContext<UserContext>({
tokenVerifyLoading: false
});
const AuthRouter: React.FC = () => (
interface AuthRouterProps {
hasToken: boolean;
}
const AuthRouter: React.FC<AuthRouterProps> = ({ hasToken }) => (
<Layout>
<Switch>
<Route path={passwordResetSuccessPath} component={ResetPasswordSuccess} />
<Route path={passwordResetPath} component={ResetPassword} />
{!hasToken ? (
<Route path={newPasswordPath} component={NewPassword} />
) : (
<LoginLoading />
)}
<Route component={LoginView} />
</Switch>
</Layout>

View file

@ -275,7 +275,7 @@ const Routes: React.FC = () => {
) : hasToken && tokenVerifyLoading ? (
<LoginLoading />
) : (
<Auth />
<Auth hasToken={hasToken} />
)
}
</AuthProvider>