Merge branch 'master' of github.com:ONLYOFFICE/CommunityServer-AspNetCore

This commit is contained in:
Alexey Safronov 2019-10-01 12:37:16 +03:00
commit 6031e45334
4 changed files with 19 additions and 32 deletions

View File

@ -31,7 +31,7 @@ const Confirm = ({ match, language }) => {
path={`${match.path}/LinkInvite`} path={`${match.path}/LinkInvite`}
component={CreateUserForm} component={CreateUserForm}
/> />
<PublicRoute <ConfirmRoute
path={`${match.path}/Activation`} path={`${match.path}/Activation`}
component={ActivateUserForm} component={ActivateUserForm}
/> />

View File

@ -44,35 +44,25 @@ const ConfirmContainer = styled.div`
`; `;
const emailInputName = 'email';
const passwordInputName = 'password';
class Confirm extends React.PureComponent { class Confirm extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
const queryParams = props.location.search.slice(1).split('&');
const arrayOfQueryParams = queryParams.map(queryParam => queryParam.split('='));
const linkParams = Object.fromEntries(arrayOfQueryParams);
const indexOfSlash = this.props.match.path.lastIndexOf('/');
const typeLink = this.props.match.path.slice(indexOfSlash + 1);
this.state = { this.state = {
email: decodeURIComponent(linkParams.email), email: props.linkData.email,
emailValid: true, firstName: props.linkData.firstname,
firstName: decodeURIComponent(linkParams.firstname),
firstNameValid: true, firstNameValid: true,
lastName: decodeURIComponent(linkParams.lastname), lastName: props.linkData.lastname,
lastNameValid: true, lastNameValid: true,
password: '', password: '',
passwordValid: true, passwordValid: true,
errorText: '', errorText: '',
isLoading: false, isLoading: false,
passwordEmpty: false, passwordEmpty: false,
queryString: `type=${typeLink}&${props.location.search.slice(1)}`, key: props.linkData.confirmHeader,
type: typeLink, linkType: props.linkData.type,
userId: linkParams.uid userId: props.linkData.uid
}; };
} }
@ -110,22 +100,19 @@ class Confirm extends React.PureComponent {
userName: this.state.email, userName: this.state.email,
password: this.state.password password: this.state.password
}; };
const personalData = { const personalData = {
firstname: this.state.firstName, firstname: this.state.firstName,
lastname: this.state.lastName, lastname: this.state.lastName
email: this.state.email
}; };
activateConfirmUser(personalData, loginData, this.state.queryString, this.state.userId, EmployeeActivationStatus.Activated) activateConfirmUser(personalData, loginData, this.state.key, this.state.userId, EmployeeActivationStatus.Activated)
.then(() => history.push('/')) .then(() => history.push('/'))
.catch(e => { .catch(e => {
console.error("activate error", e); console.error("activate error", e);
this.setState({ errorText: e.message }); this.setState({ errorText: e.message });
this.setState({ isLoading: false }); this.setState({ isLoading: false });
}); });
}); });
}; };
@ -141,7 +128,7 @@ class Confirm extends React.PureComponent {
componentDidMount() { componentDidMount() {
const { getConfirmationInfo, history } = this.props; const { getConfirmationInfo, history } = this.props;
getConfirmationInfo(this.state.queryString) getConfirmationInfo(this.state.key, this.state.linkType)
.then( .then(
function () { function () {
console.log("get settings success"); console.log("get settings success");
@ -173,7 +160,6 @@ class Confirm extends React.PureComponent {
this.state.errorText && this.setState({ errorText: "" });; this.state.errorText && this.setState({ errorText: "" });;
} }
onChangePassword = event => { onChangePassword = event => {
this.setState({ password: event.target.value }); this.setState({ password: event.target.value });
!this.state.passwordValid && this.setState({ passwordValid: true }); !this.state.passwordValid && this.setState({ passwordValid: true });
@ -244,8 +230,8 @@ class Confirm extends React.PureComponent {
<PasswordInput <PasswordInput
className='confirm-row' className='confirm-row'
id='password' id='password'
inputName={passwordInputName} inputName='password'
emailInputName={emailInputName} emailInputName='surname'
inputValue={this.state.password} inputValue={this.state.password}
placeholder={t('InvitePassword')} placeholder={t('InvitePassword')}
size='huge' size='huge'

View File

@ -1,5 +1,6 @@
const decomposeLink = (url, querySearch) => { const decomposeConfirmLink = (url, querySearch) => {
const queryString = querySearch.slice(1).split('&'); const decodedString = decodeURIComponent(querySearch);
const queryString = decodedString.slice(1).split('&');
const arrayOfQueryString = queryString.map(queryParam => queryParam.split('=')); const arrayOfQueryString = queryString.map(queryParam => queryParam.split('='));
const queryParams = Object.fromEntries(arrayOfQueryString); const queryParams = Object.fromEntries(arrayOfQueryString);
const posSeparator = url.lastIndexOf('/'); const posSeparator = url.lastIndexOf('/');
@ -8,4 +9,4 @@ const decomposeLink = (url, querySearch) => {
return data; return data;
} }
export default decomposeLink; export default decomposeConfirmLink;

View File

@ -171,14 +171,14 @@ export function changeEmail(userId, email, key) {
} }
export function activateConfirmUser(personalData, loginData, key, userId, activationStatus) { export function activateConfirmUser(personalData, loginData, key, userId, activationStatus) {
const data = Object.assign({}, personalData, loginData);
const changedData = { const changedData = {
id: userId, id: userId,
FirstName: personalData.firstname, FirstName: personalData.firstname,
LastName: personalData.lastname LastName: personalData.lastname
} }
return dispatch => { return dispatch => {
return api.changePassword(userId, data, key) return api.changePassword(userId, { password: loginData.password }, key)
.then(res => { .then(res => {
checkResponseError(res); checkResponseError(res);
console.log('set password success:', res.data.response); console.log('set password success:', res.data.response);