Merge pull request #378 from mirumee/fix/password-reset

Do not render password change if authenticating
This commit is contained in:
Marcin Gębala 2020-01-21 10:11:53 +01:00 committed by GitHub
commit 4633714dcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View file

@ -27,6 +27,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Throw error when API_URI is not set - #375 by @dominik-zeglen
- Fix variant stock input - #377 by @dominik-zeglen
- Add filtering to views - #361 by @dominik-zeglen
- Do not render password change if authenticating - #378 by @dominik-zeglen
## 2.0.0

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} />
<Route path={newPasswordPath} component={NewPassword} />
{!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>