2019-12-07 16:58:52 +05:30
|
|
|
import React from 'react';
|
2017-05-26 00:41:57 +05:30
|
|
|
import { Route, Switch, Redirect } from 'react-router-dom';
|
2019-12-08 00:32:00 +05:30
|
|
|
import AppInfo from 'app/components/auth/appInfo/AppInfo';
|
|
|
|
import PanelTransition from 'app/components/auth/PanelTransition';
|
|
|
|
import Register from 'app/components/auth/register/Register';
|
|
|
|
import Login from 'app/components/auth/login/Login';
|
|
|
|
import Permissions from 'app/components/auth/permissions/Permissions';
|
|
|
|
import ChooseAccount from 'app/components/auth/chooseAccount/ChooseAccount';
|
|
|
|
import Activation from 'app/components/auth/activation/Activation';
|
|
|
|
import ResendActivation from 'app/components/auth/resendActivation/ResendActivation';
|
|
|
|
import Password from 'app/components/auth/password/Password';
|
|
|
|
import AcceptRules from 'app/components/auth/acceptRules/AcceptRules';
|
|
|
|
import ForgotPassword from 'app/components/auth/forgotPassword/ForgotPassword';
|
|
|
|
import RecoverPassword from 'app/components/auth/recoverPassword/RecoverPassword';
|
|
|
|
import Mfa from 'app/components/auth/mfa/Mfa';
|
|
|
|
import Finish from 'app/components/auth/finish/Finish';
|
2019-06-30 19:02:50 +05:30
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
2019-12-08 00:32:00 +05:30
|
|
|
import { RootState } from 'app/reducers';
|
|
|
|
import { Client } from 'app/components/auth/reducer';
|
2017-05-26 00:41:57 +05:30
|
|
|
|
2016-01-04 02:48:42 +05:30
|
|
|
import styles from './auth.scss';
|
|
|
|
|
2018-01-01 22:54:14 +05:30
|
|
|
// TODO: after migrating to new react router (posibly) this view started remounting
|
|
|
|
// after route change e.g. /login -> /password which results in state dropping
|
|
|
|
// we should find why this view is remounting or move isSidebarHidden into store
|
|
|
|
// so that it persist disregarding remounts
|
|
|
|
let isSidebarHiddenCache = false;
|
|
|
|
|
2019-12-07 16:58:52 +05:30
|
|
|
interface Props {
|
|
|
|
client: Client | null;
|
|
|
|
}
|
2019-06-30 19:02:50 +05:30
|
|
|
|
2019-12-07 16:58:52 +05:30
|
|
|
class AuthPage extends React.Component<
|
2019-11-27 14:33:32 +05:30
|
|
|
Props,
|
|
|
|
{
|
2019-12-07 16:58:52 +05:30
|
|
|
isSidebarHidden: boolean;
|
|
|
|
}
|
2019-11-27 14:33:32 +05:30
|
|
|
> {
|
|
|
|
state = {
|
|
|
|
isSidebarHidden: isSidebarHiddenCache,
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { isSidebarHidden } = this.state;
|
|
|
|
const { client } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div
|
|
|
|
className={isSidebarHidden ? styles.hiddenSidebar : styles.sidebar}
|
|
|
|
>
|
|
|
|
<AppInfo {...client} onGoToAuth={this.onGoToAuth} />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.content} data-e2e-content>
|
|
|
|
<Switch>
|
|
|
|
<Route path="/login" render={renderPanelTransition(Login)} />
|
|
|
|
<Route path="/mfa" render={renderPanelTransition(Mfa)} />
|
|
|
|
<Route path="/password" render={renderPanelTransition(Password)} />
|
|
|
|
<Route path="/register" render={renderPanelTransition(Register)} />
|
|
|
|
<Route
|
|
|
|
path="/activation/:key?"
|
|
|
|
render={renderPanelTransition(Activation)}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/resend-activation"
|
|
|
|
render={renderPanelTransition(ResendActivation)}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/oauth/permissions"
|
|
|
|
render={renderPanelTransition(Permissions)}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/choose-account"
|
|
|
|
render={renderPanelTransition(ChooseAccount)}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/oauth/choose-account"
|
|
|
|
render={renderPanelTransition(ChooseAccount)}
|
|
|
|
/>
|
|
|
|
<Route path="/oauth/finish" component={Finish} />
|
|
|
|
<Route
|
|
|
|
path="/accept-rules"
|
|
|
|
render={renderPanelTransition(AcceptRules)}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/forgot-password"
|
|
|
|
render={renderPanelTransition(ForgotPassword)}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="/recover-password/:key?"
|
|
|
|
render={renderPanelTransition(RecoverPassword)}
|
|
|
|
/>
|
|
|
|
<Redirect to="/404" />
|
|
|
|
</Switch>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onGoToAuth = () => {
|
|
|
|
isSidebarHiddenCache = true;
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
isSidebarHidden: true,
|
|
|
|
});
|
|
|
|
};
|
2016-01-21 11:59:35 +05:30
|
|
|
}
|
2016-02-23 11:27:16 +05:30
|
|
|
|
2017-05-26 00:41:57 +05:30
|
|
|
function renderPanelTransition(factory) {
|
2019-11-27 14:33:32 +05:30
|
|
|
const { Title, Body, Footer, Links } = factory();
|
|
|
|
|
|
|
|
return props => (
|
|
|
|
<PanelTransition
|
|
|
|
key="panel-transition"
|
|
|
|
Title={<Title />}
|
|
|
|
Body={<Body {...props} />}
|
|
|
|
Footer={<Footer />}
|
|
|
|
Links={<Links />}
|
|
|
|
/>
|
|
|
|
);
|
2017-05-26 00:41:57 +05:30
|
|
|
}
|
|
|
|
|
2019-11-27 14:33:32 +05:30
|
|
|
export default withRouter(
|
2019-12-07 16:58:52 +05:30
|
|
|
connect((state: RootState) => ({
|
2019-11-27 14:33:32 +05:30
|
|
|
client: state.auth.client,
|
|
|
|
}))(AuthPage),
|
|
|
|
);
|