Skip to content

Commit 9084159

Browse files
Able to change expired password (#152)
- Before, we were getting error when we tried to change the expired password, this has been fixed in this change. - Defect: https://jazz07.rchland.ibm.com:13443/jazz/web/projects/CSSD#action=com.ibm.team.workitem.viewWorkItem&id=578660 Signed-off-by: Nikhil Ashoka <[email protected]>
1 parent af91da4 commit 9084159

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

src/store/modules/SecurityAndAccess/UserManagementStore.js

+39-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const UserManagementStore = {
153153
}
154154
});
155155
},
156-
async updateUser(
156+
async updateUserfromUserManagement(
157157
{ dispatch },
158158
{
159159
originalUsername,
@@ -205,6 +205,44 @@ const UserManagementStore = {
205205
throw new Error(message);
206206
});
207207
},
208+
async updateUser(
209+
{ dispatch },
210+
{ originalUsername, username, password, privilege, status, locked }
211+
) {
212+
const data = {};
213+
if (username) data.UserName = username;
214+
if (password) data.Password = password;
215+
if (privilege) data.RoleId = privilege;
216+
if (status !== undefined) data.Enabled = status;
217+
if (locked !== undefined) data.Locked = locked;
218+
return await api
219+
.patch(`/redfish/v1/AccountService/Accounts/${originalUsername}`, data)
220+
.then(() => dispatch('getUsers'))
221+
.then(() =>
222+
i18n.t('pageUserManagement.toast.successUpdateUser', {
223+
username: originalUsername,
224+
})
225+
)
226+
.catch((error) => {
227+
console.log(error);
228+
229+
const messageId =
230+
error.response.data['[email protected]'][0].MessageId;
231+
232+
const message =
233+
messageId === 'Base.1.8.1.PropertyValueFormatError'
234+
? i18n.t(
235+
'pageUserManagement.toast.errorUpdateUserPasswordNotAccepted',
236+
{
237+
username: originalUsername,
238+
}
239+
)
240+
: i18n.t('pageUserManagement.toast.errorUpdateUser', {
241+
username: originalUsername,
242+
});
243+
throw new Error(message);
244+
});
245+
},
208246
async deleteUser({ dispatch }, username) {
209247
return await api
210248
.delete(`/redfish/v1/AccountService/Accounts/${username}`)

src/views/ChangePassword/ChangePassword.vue

+9-6
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,15 @@ export default {
123123
password: this.form.password,
124124
};
125125
126-
Promise.all([
127-
this.$store.dispatch('userManagement/updateUser', data),
128-
this.$store.dispatch('userManagement/getUsers'),
129-
this.$store.dispatch('global/getCurrentUser', this.username),
130-
this.$store.dispatch('global/getSystemInfo'),
131-
])
126+
this.$store
127+
.dispatch('userManagement/updateUser', data)
128+
.then(() => {
129+
Promise.all([
130+
this.$store.dispatch('userManagement/getUsers'),
131+
this.$store.dispatch('global/getCurrentUser', this.username),
132+
this.$store.dispatch('global/getSystemInfo'),
133+
]);
134+
})
132135
.then(() => this.$router.push('/'))
133136
.catch(() => (this.changePasswordError = true));
134137
},

src/views/SecurityAndAccess/UserManagement/UserManagement.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export default {
317317
.finally(() => this.endLoader());
318318
} else {
319319
this.$store
320-
.dispatch('userManagement/updateUser', userData)
320+
.dispatch('userManagement/updateUserfromUserManagement', userData)
321321
.then((success) => this.successToast(success))
322322
.catch(({ message }) => this.errorToast(message))
323323
.finally(() => this.endLoader());

0 commit comments

Comments
 (0)