2017-06-13 00:40:18 +05:30
|
|
|
// @flow
|
|
|
|
import React, { Component } from 'react';
|
2016-02-23 11:27:16 +05:30
|
|
|
|
2017-05-26 00:41:57 +05:30
|
|
|
import { Route, Switch, Redirect } from 'react-router-dom';
|
2016-01-18 10:58:43 +05:30
|
|
|
|
2016-03-13 14:20:09 +05:30
|
|
|
import AppInfo from 'components/auth/appInfo/AppInfo';
|
2016-01-31 18:29:38 +05:30
|
|
|
import PanelTransition from 'components/auth/PanelTransition';
|
2016-01-04 02:48:42 +05:30
|
|
|
|
2017-05-26 00:41:57 +05:30
|
|
|
import Register from 'components/auth/register/Register';
|
|
|
|
import Login from 'components/auth/login/Login';
|
|
|
|
import Permissions from 'components/auth/permissions/Permissions';
|
|
|
|
import ChooseAccount from 'components/auth/chooseAccount/ChooseAccount';
|
|
|
|
import Activation from 'components/auth/activation/Activation';
|
|
|
|
import ResendActivation from 'components/auth/resendActivation/ResendActivation';
|
|
|
|
import Password from 'components/auth/password/Password';
|
|
|
|
import AcceptRules from 'components/auth/acceptRules/AcceptRules';
|
|
|
|
import ForgotPassword from 'components/auth/forgotPassword/ForgotPassword';
|
|
|
|
import RecoverPassword from 'components/auth/recoverPassword/RecoverPassword';
|
2017-08-23 00:09:08 +05:30
|
|
|
import Mfa from 'components/auth/mfa/Mfa';
|
2017-05-26 00:41:57 +05:30
|
|
|
import Finish from 'components/auth/finish/Finish';
|
2019-06-30 19:02:50 +05:30
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
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-06-30 19:02:50 +05:30
|
|
|
type OwnProps = {|
|
|
|
|
|};
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
...OwnProps,
|
2017-08-23 02:01:41 +05:30
|
|
|
client: {
|
|
|
|
id: string,
|
|
|
|
name: string,
|
|
|
|
description: string
|
|
|
|
}
|
2019-06-30 19:02:50 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
class AuthPage extends Component<Props, {
|
2017-08-23 02:01:41 +05:30
|
|
|
isSidebarHidden: bool
|
|
|
|
}> {
|
2016-02-06 16:17:51 +05:30
|
|
|
state = {
|
2018-01-01 22:54:14 +05:30
|
|
|
isSidebarHidden: isSidebarHiddenCache
|
2016-02-06 16:17:51 +05:30
|
|
|
};
|
2016-01-16 17:36:22 +05:30
|
|
|
|
2016-01-04 02:48:42 +05:30
|
|
|
render() {
|
2016-02-23 11:27:16 +05:30
|
|
|
const {isSidebarHidden} = this.state;
|
|
|
|
const {client} = this.props;
|
2016-01-04 02:48:42 +05:30
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2016-02-06 16:17:51 +05:30
|
|
|
<div className={isSidebarHidden ? styles.hiddenSidebar : styles.sidebar}>
|
2016-02-23 11:27:16 +05:30
|
|
|
<AppInfo {...client} onGoToAuth={this.onGoToAuth} />
|
2016-01-04 02:48:42 +05:30
|
|
|
</div>
|
2017-06-13 00:40:18 +05:30
|
|
|
|
2018-02-18 23:39:32 +05:30
|
|
|
<div className={styles.content} data-e2e-content>
|
2017-05-26 00:41:57 +05:30
|
|
|
<Switch>
|
|
|
|
<Route path="/login" render={renderPanelTransition(Login)} />
|
2017-08-23 00:09:08 +05:30
|
|
|
<Route path="/mfa" render={renderPanelTransition(Mfa)} />
|
2017-05-26 00:41:57 +05:30
|
|
|
<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)} />
|
2018-02-18 01:29:35 +05:30
|
|
|
<Route path="/choose-account" render={renderPanelTransition(ChooseAccount)} />
|
2017-05-26 00:41:57 +05:30
|
|
|
<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>
|
2016-01-04 02:48:42 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-02-06 16:17:51 +05:30
|
|
|
|
|
|
|
onGoToAuth = () => {
|
2018-01-01 22:54:14 +05:30
|
|
|
isSidebarHiddenCache = true;
|
|
|
|
|
2016-02-06 16:17:51 +05:30
|
|
|
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) {
|
|
|
|
const {Title, Body, Footer, Links} = factory();
|
2017-08-23 00:09:08 +05:30
|
|
|
|
2017-05-26 00:41:57 +05:30
|
|
|
return (props) => (
|
|
|
|
<PanelTransition
|
|
|
|
key="panel-transition"
|
|
|
|
Title={<Title />}
|
|
|
|
Body={<Body {...props} />}
|
|
|
|
Footer={<Footer />}
|
|
|
|
Links={<Links />}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-06-30 19:02:50 +05:30
|
|
|
export default withRouter(connect<Props, OwnProps, _, _, _, _>((state) => ({
|
2016-02-23 11:27:16 +05:30
|
|
|
client: state.auth.client
|
2017-05-26 00:41:57 +05:30
|
|
|
}))(AuthPage));
|