Fixed confirm link user creation
This commit is contained in:
parent
0784453daf
commit
2baf8cbc76
@ -39,8 +39,7 @@ class App extends React.Component {
|
||||
getUser,
|
||||
getModules,
|
||||
setIsLoaded,
|
||||
getIsAuthenticated,
|
||||
//defaultPage
|
||||
getIsAuthenticated
|
||||
} = this.props;
|
||||
|
||||
getIsAuthenticated()
|
||||
@ -49,11 +48,6 @@ class App extends React.Component {
|
||||
if (!isAuthenticated) {
|
||||
requests.push(getPortalSettings());
|
||||
} else if (!window.location.pathname.includes("confirm/EmailActivation")) {
|
||||
|
||||
// debugger;
|
||||
// if(utils.tryRedirectTo(defaultPage)) //TODO: Re-write redirect to defaultPage after get settings
|
||||
// return;
|
||||
|
||||
requests.push(getUser());
|
||||
requests.push(getPortalSettings());
|
||||
requests.push(getModules());
|
||||
@ -114,12 +108,11 @@ class App extends React.Component {
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const { modules, isLoaded, settings } = state.auth;
|
||||
const { organizationName, defaultPage } = settings;
|
||||
const { organizationName } = settings;
|
||||
return {
|
||||
modules,
|
||||
isLoaded,
|
||||
organizationName,
|
||||
defaultPage
|
||||
organizationName
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -2,9 +2,12 @@ import React, { Suspense, lazy, useEffect } from "react";
|
||||
import { Route, Switch } from "react-router-dom";
|
||||
import ConfirmRoute from "../../../helpers/confirmRoute";
|
||||
import { I18nextProvider } from "react-i18next";
|
||||
import { Error404, utils } from "asc-web-common";
|
||||
|
||||
import { Error404, utils, store, PageLayout, Loaders } from "asc-web-common";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
const { getIsLoaded } = store.auth.selectors;
|
||||
|
||||
const i18n = createI18N({
|
||||
page: "Confirm",
|
||||
localesPath: "pages/Confirm",
|
||||
@ -23,13 +26,19 @@ const ChangePhoneForm = lazy(() => import("./sub-components/changePhone"));
|
||||
const ProfileRemoveForm = lazy(() => import("./sub-components/profileRemove"));
|
||||
const ChangeOwnerForm = lazy(() => import("./sub-components/changeOwner"));
|
||||
|
||||
const Confirm = ({ match }) => {
|
||||
const Confirm = ({ match, isLoaded }) => {
|
||||
useEffect(() => {
|
||||
changeLanguage(i18n);
|
||||
}, []);
|
||||
|
||||
//console.log("Confirm render");
|
||||
return (
|
||||
!isLoaded ? <PageLayout>
|
||||
<PageLayout.SectionBody>
|
||||
<Loaders.Rectangle height="90vh"/>
|
||||
</PageLayout.SectionBody>
|
||||
</PageLayout> :
|
||||
|
||||
<I18nextProvider i18n={i18n}>
|
||||
<Suspense fallback={null}>
|
||||
<Switch>
|
||||
@ -80,4 +89,10 @@ const Confirm = ({ match }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default Confirm;
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
isLoaded: getIsLoaded(state)
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(Confirm);
|
||||
|
@ -19,7 +19,7 @@ import {
|
||||
createConfirmUser,
|
||||
} from "../../../../store/confirm/actions";
|
||||
const { logout, login } = store.auth.actions;
|
||||
const { createPasswordHash } = commonUtils;
|
||||
const { createPasswordHash, tryRedirectTo } = commonUtils;
|
||||
const inputWidth = "400px";
|
||||
|
||||
const ConfirmContainer = styled.div`
|
||||
@ -89,7 +89,7 @@ class Confirm extends React.PureComponent {
|
||||
|
||||
onSubmit = () => {
|
||||
this.setState({ isLoading: true }, () => {
|
||||
const { history, createConfirmUser, linkData, hashSettings } = this.props;
|
||||
const { defaultPage, createConfirmUser, linkData, hashSettings } = this.props;
|
||||
const isVisitor = parseInt(linkData.emplType) === 2;
|
||||
|
||||
this.setState({ errorText: "" });
|
||||
@ -142,7 +142,7 @@ class Confirm extends React.PureComponent {
|
||||
createConfirmUser(registerData, loginData, this.state.key)
|
||||
.then(() => {
|
||||
toastr.success("User has been created successfully");
|
||||
return history.push("/");
|
||||
tryRedirectTo(defaultPage);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("confirm error", error);
|
||||
@ -368,6 +368,7 @@ function mapStateToProps(state) {
|
||||
settings: state.auth.settings.passwordSettings,
|
||||
greetingTitle: state.auth.settings.greetingSettings,
|
||||
hashSettings: state.auth.settings.hashSettings,
|
||||
defaultPage: state.auth.settings.defaultPage
|
||||
};
|
||||
}
|
||||
|
||||
@ -375,5 +376,5 @@ export default connect(mapStateToProps, {
|
||||
getConfirmationInfo,
|
||||
createConfirmUser,
|
||||
login,
|
||||
logout,
|
||||
logout
|
||||
})(withRouter(withTranslation()(CreateUserForm)));
|
||||
|
@ -4,7 +4,8 @@ import { ValidationResult } from "./../helpers/constants";
|
||||
import { Loader } from "asc-web-components";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router";
|
||||
import { api, utils, PageLayout } from "asc-web-common";
|
||||
import { api, utils, PageLayout, store } from "asc-web-common";
|
||||
const { isAuthenticated } = store.auth.selectors;
|
||||
const { checkConfirmLink } = api.user;
|
||||
const { getObjectByLocation } = utils;
|
||||
|
||||
@ -99,7 +100,7 @@ class ConfirmRoute extends React.Component {
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
isAuthenticated: state.auth.isAuthenticated,
|
||||
isAuthenticated: isAuthenticated(state)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,25 @@ export function createConfirmUser(registerData, loginData, key) {
|
||||
return (dispatch) => {
|
||||
return api.people
|
||||
.createUser(data, key)
|
||||
.then((user) => dispatch(setCurrentUser(user)))
|
||||
.then(() => api.user.login(loginData.userName, loginData.passwordHash))
|
||||
.then(() => loadInitInfo(dispatch));
|
||||
.then((user) => {
|
||||
dispatch(setCurrentUser(user));
|
||||
|
||||
})
|
||||
.then(() => {
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
login(loginData.userName, loginData.passwordHash)(dispatch)
|
||||
.then(() => {
|
||||
resolve(loadInitInfo(dispatch));
|
||||
})
|
||||
.catch((e) => {
|
||||
reject(e);
|
||||
})
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
return promise;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ const PrivateRoute = ({ component: Component, ...rest }) => {
|
||||
return (
|
||||
<PageLayout>
|
||||
<PageLayout.SectionBody>
|
||||
<RectangleLoader height="80vh"/>
|
||||
<RectangleLoader height="90vh"/>
|
||||
</PageLayout.SectionBody>
|
||||
</PageLayout>
|
||||
);
|
||||
|
@ -2,11 +2,24 @@
|
||||
import React from "react";
|
||||
import { Redirect, Route } from "react-router-dom";
|
||||
import { connect } from "react-redux";
|
||||
import { getIsLoaded, isAuthenticated } from "../../store/auth/selectors";
|
||||
import PageLayout from "../PageLayout";
|
||||
import RectangleLoader from "../Loaders/RectangleLoader/RectangleLoader";
|
||||
|
||||
export const PublicRoute = ({ component: Component, ...rest }) => {
|
||||
const { wizardToken, wizardCompleted, isAuthenticated } = rest;
|
||||
const { wizardToken, wizardCompleted, isAuthenticated, isLoaded } = rest;
|
||||
|
||||
const renderComponent = (props) => {
|
||||
if(!isLoaded) {
|
||||
return (
|
||||
<PageLayout>
|
||||
<PageLayout.SectionBody>
|
||||
<RectangleLoader height="90vh"/>
|
||||
</PageLayout.SectionBody>
|
||||
</PageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
if (isAuthenticated) {
|
||||
return (
|
||||
<Redirect
|
||||
@ -35,10 +48,14 @@ export const PublicRoute = ({ component: Component, ...rest }) => {
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const { settings } = state.auth;
|
||||
const {wizardToken, wizardCompleted} = settings;
|
||||
return {
|
||||
isAuthenticated: state.auth.isAuthenticated,
|
||||
wizardToken: state.auth.settings.wizardToken,
|
||||
wizardCompleted: state.auth.settings.wizardCompleted,
|
||||
isAuthenticated: isAuthenticated(state),
|
||||
isLoaded: getIsLoaded(state),
|
||||
|
||||
wizardToken,
|
||||
wizardCompleted,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user