Skip to content

Commit 451f23a

Browse files
authored
Improve change password user experience (#3058)
1 parent 300ebfa commit 451f23a

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

portal-ui/src/screens/Console/Account/ChangePasswordModal.tsx

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ import {
2626
import ModalWrapper from "../Common/ModalWrapper/ModalWrapper";
2727

2828
import { modalStyleUtils } from "../Common/FormComponents/common/styleLibrary";
29-
import { setModalErrorSnackMessage } from "../../../systemSlice";
29+
import {
30+
setErrorSnackMessage,
31+
setModalErrorSnackMessage,
32+
setSnackBarMessage,
33+
} from "../../../systemSlice";
3034
import { useAppDispatch } from "../../../store";
3135
import { api } from "api";
32-
import { AccountChangePasswordRequest } from "api/consoleApi";
36+
import { AccountChangePasswordRequest, ApiError } from "api/consoleApi";
3337
import { errorToHandler } from "api/errors";
38+
import WarningMessage from "../Common/WarningMessage/WarningMessage";
3439

3540
interface IChangePasswordProps {
3641
open: boolean;
@@ -86,14 +91,16 @@ const ChangePassword = ({ open, closeModal }: IChangePasswordProps) => {
8691
setNewPassword("");
8792
setReNewPassword("");
8893
setCurrentPassword("");
94+
dispatch(setSnackBarMessage("Successfully updated the password."));
8995
closeModal();
9096
})
91-
.catch((err) => {
97+
.catch(async (res) => {
9298
setLoading(false);
9399
setNewPassword("");
94100
setReNewPassword("");
95101
setCurrentPassword("");
96-
dispatch(setModalErrorSnackMessage(errorToHandler(err)));
102+
const err = (await res.json()) as ApiError;
103+
dispatch(setErrorSnackMessage(errorToHandler(err)));
97104
});
98105
};
99106

@@ -113,6 +120,25 @@ const ChangePassword = ({ open, closeModal }: IChangePasswordProps) => {
113120
This will change your Console password. Please note your new password
114121
down, as it will be required to log into Console after this session.
115122
</div>
123+
<WarningMessage
124+
title={""}
125+
label={
126+
<div>
127+
<div>
128+
If you are looking to change MINIO_ROOT_USER credentials, Please
129+
refer to{" "}
130+
<a
131+
target="_blank"
132+
rel="noopener"
133+
href="https://min.io/docs/minio/linux/administration/identity-access-management/minio-user-management.html#id4?ref=con"
134+
>
135+
rotating
136+
</a>{" "}
137+
credentials .
138+
</div>
139+
</div>
140+
}
141+
/>
116142
<form
117143
noValidate
118144
autoComplete="off"

portal-ui/src/screens/Console/Account/ChangeUserPasswordModal.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ import {
2424
ProgressBar,
2525
} from "mds";
2626
import { modalStyleUtils } from "../Common/FormComponents/common/styleLibrary";
27-
import { setModalErrorSnackMessage } from "../../../systemSlice";
27+
import {
28+
setErrorSnackMessage,
29+
setModalErrorSnackMessage,
30+
setSnackBarMessage,
31+
} from "../../../systemSlice";
2832
import { useAppDispatch } from "../../../store";
2933
import { api } from "api";
30-
import { ChangeUserPasswordRequest } from "api/consoleApi";
34+
import { ApiError, ChangeUserPasswordRequest } from "api/consoleApi";
3135
import { errorToHandler } from "api/errors";
3236
import ModalWrapper from "../Common/ModalWrapper/ModalWrapper";
3337

@@ -77,13 +81,19 @@ const ChangeUserPassword = ({
7781
setLoading(false);
7882
setNewPassword("");
7983
setReNewPassword("");
84+
dispatch(
85+
setSnackBarMessage(
86+
`Successfully updated the password for the user ${userName}.`,
87+
),
88+
);
8089
closeModal();
8190
})
82-
.catch((err) => {
91+
.catch(async (res) => {
8392
setLoading(false);
8493
setNewPassword("");
8594
setReNewPassword("");
86-
dispatch(setModalErrorSnackMessage(errorToHandler(err)));
95+
const err = (await res.json()) as ApiError;
96+
dispatch(setErrorSnackMessage(errorToHandler(err)));
8797
});
8898
};
8999

portal-ui/src/screens/Console/Users/UserDetails.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ const UserDetails = () => {
351351
onClick={changeUserPassword}
352352
icon={<PasswordKeyIcon />}
353353
variant={"regular"}
354+
disabled={userLoggedIn === userName}
354355
/>
355356
</TooltipWrapper>
356357
</Fragment>

0 commit comments

Comments
 (0)