Skip to content

Commit

Permalink
Merge pull request #2318 from mendersoftware/cherry-3.1.x-men-5331
Browse files Browse the repository at this point in the history
[Cherry 3.1.x]: MEN-5331 - fixed an issue that limited profile edits to passwords
  • Loading branch information
mzedel committed Dec 21, 2021
2 parents 9dcc584 + 7bc52e2 commit 52a9dd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
9 changes: 7 additions & 2 deletions src/js/actions/userActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,14 @@ export const removeUser = userId => dispatch =>
)
.catch(err => userActionErrorHandler(err, 'remove', dispatch));

export const editUser = (userId, userData) => dispatch =>
export const editUser = (userId, userData) => (dispatch, getState) =>
GeneralApi.put(`${useradmApiUrl}/users/${userId}`, userData)
.then(() => Promise.all([dispatch({ type: UserConstants.UPDATED_USER, userId, user: userData }), dispatch(setSnackbar(actions.edit.successMessage))]))
.then(() =>
Promise.all([
dispatch({ type: UserConstants.UPDATED_USER, userId: userId === UserConstants.OWN_USER_ID ? getState().users.currentUser : userId, user: userData }),
dispatch(setSnackbar(actions.edit.successMessage))
])
)
.catch(err => userActionErrorHandler(err, 'edit', dispatch));

export const enableUser2fa = (userId = OWN_USER_ID) => dispatch =>
Expand Down
16 changes: 6 additions & 10 deletions src/js/components/user-management/selfusermanagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ export const SelfUserManagement = ({ canHave2FA, currentUser, editUser, hasTrack
if (userData.password != userData.password_confirmation) {
setSnackbar(`The passwords don't match`);
} else {
const data = {
current_password: userData.current_password,
password: userData.password
};
editUser(UserConstants.OWN_USER_ID, data).then(() => {
editUser(UserConstants.OWN_USER_ID, userData).then(() => {
setEditEmail(false);
setEditPass(false);
});
Expand Down Expand Up @@ -73,14 +69,14 @@ export const SelfUserManagement = ({ canHave2FA, currentUser, editUser, hasTrack
uniqueId={emailFormId}
>
<TextInput
disabled={false}
focus
hint="Email"
label="Email"
id="email"
disabled={false}
value={email}
validations="isLength:1,isEmail"
focus={true}
InputLabelProps={{ shrink: !!email }}
label="Email"
validations="isLength:1,isEmail"
value={email}
/>
</Form>
)}
Expand Down

0 comments on commit 52a9dd8

Please sign in to comment.