Skip to content

Commit

Permalink
fix(app-admin-users-cognito): add REACT_APP_ADMIN_USER_CAN_CHANGE_EMAIL
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Oct 29, 2021
1 parent 602494f commit d6c50cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -65,6 +65,8 @@ const UserAccountForm = () => {

const user = currentUser.loading ? {} : currentUser.data.adminUsers.user.data;

const emailIsDisabled = process.env.REACT_APP_ADMIN_USER_CAN_CHANGE_EMAIL === "false";

return (
<Grid>
<Cell span={3} />
Expand Down Expand Up @@ -106,6 +108,7 @@ const UserAccountForm = () => {
<Input
value={data.email}
label={t`Email`}
disabled={emailIsDisabled}
description={
"Email is your unique identifier used to login!"
}
Expand Down
Expand Up @@ -132,7 +132,15 @@ export class UsersFormView extends UIView {
name: "email",
label: "Email",
validators: () => validation.create("required,email"),
beforeChange: (value: string, cb) => cb(value.toLowerCase())
beforeChange: (value: string, cb) => cb(value.toLowerCase()),
isDisabled: () => {
const { isNewUser } = this.getUserFormHook();
if (isNewUser) {
return false;
}

return process.env.REACT_APP_ADMIN_USER_CAN_CHANGE_EMAIL === "false";
}
})
);

Expand Down

0 comments on commit d6c50cc

Please sign in to comment.