@@ -20,7 +24,14 @@ const BulletItem = ({ text }) => (
const healthStatusCheck_key = '__or__healthStatusCheck_key'
+@connect(
+ (state, props) => ({
+ loading: state.getIn(['user', 'loginRequest', 'loading']),
+ authDetails: state.getIn(['user', 'authDetails']),
+ }), { fetchTenants }
+)
@withPageTitle('Signup - OpenReplay')
+@withRouter
export default class Signup extends React.Component {
state = {
healthModalPassed: localStorage.getItem(healthStatusCheck_key === 'true'),
@@ -28,6 +39,19 @@ export default class Signup extends React.Component {
healthStatus: null,
}
+ static getDerivedStateFromProps(nextProps, prevState) {
+ const { authDetails } = nextProps;
+ if (Object.keys(authDetails).length === 0) {
+ return null;
+ }
+
+ if (authDetails.tenants) {
+ nextProps.history.push(LOGIN_ROUTE);
+ }
+
+ return null;
+ }
+
getHealth = async () => {
this.setState({ healthStatusLoading: true });
const { healthMap } = await getHealthRequest();
@@ -36,6 +60,11 @@ export default class Signup extends React.Component {
componentDidMount() {
if (!this.state.healthModalPassed) void this.getHealth();
+
+ const { authDetails } = this.props;
+ if (Object.keys(authDetails).length === 0) {
+ this.props.fetchTenants();
+ }
}
setHealthModalPassed = () => {