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

View file

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