Skip to content

Commit

Permalink
refactor: ♻️ Ensure requirePasswordChange is true when setRandomPassw…
Browse files Browse the repository at this point in the history
…ord is true

Created some logic to make sure the requirePasswordChange field will be true even if the user changed it to false and then changed setRandomPassword to true. Also changed some strings and sizes to follow figma specs.
  • Loading branch information
rique223 committed Oct 16, 2023
1 parent ff44564 commit 48f3e33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions apps/meteor/client/views/admin/users/AdminUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ const UserForm = ({ userData, onReload, setCreatedUsersCount, ...props }: AdminU
mode: 'onBlur',
});

const { avatar, username, setRandomPassword, password } = watch();

useEffect(() => {
resetField('sendWelcomeEmail', { defaultValue: isSmtpEnabled });
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -117,6 +119,12 @@ const UserForm = ({ userData, onReload, setCreatedUsersCount, ...props }: AdminU
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isSmtpEnabled, userData?._id]);

useEffect(() => {
resetField('requirePasswordChange', { defaultValue: setRandomPassword });

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [setRandomPassword]);

const eventStats = useEndpointAction('POST', '/v1/statistics.telemetry');
const updateUserAction = useEndpoint('POST', '/v1/users.update');
const createUserAction = useEndpoint('POST', '/v1/users.create');
Expand All @@ -126,8 +134,6 @@ const UserForm = ({ userData, onReload, setCreatedUsersCount, ...props }: AdminU

const availableRoles: SelectOption[] = roleData?.roles.map(({ _id, name, description }) => [_id, description || name]) || [];

const { avatar, username, setRandomPassword, password } = watch();

const updateAvatar = useUpdateAvatar(avatar, userData?._id || '');

const handleUpdateUser = useMutation({
Expand Down Expand Up @@ -238,7 +244,7 @@ const UserForm = ({ userData, onReload, setCreatedUsersCount, ...props }: AdminU
<FieldLabel htmlFor={verifiedId} p={0} disabled={!isSmtpEnabled || !isVerificationNeeded}>
{t('Mark_email_as_verified')}
</FieldLabel>
<Icon name='info-circled' size='x21' mis={8} title={t('Activate_to_bypass_email_verification')} color='default' />
<Icon name='info-circled' size='x20' mis={8} title={t('Enable_to_bypass_email_verification')} color='default' />
</Box>
<Controller
control={control}
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
"Action_Available_After_Custom_Content_Added": "This action will become available after the custom content has been added",
"Action_Available_After_Custom_Content_Added_And_Visible": "This action will become available after the custom content has been added and made visible to everyone",
"Activate": "Activate",
"Activate_to_bypass_email_verification": "Activate to bypass email verification",
"Enable_to_bypass_email_verification": "Enable to bypass email verification",
"Active": "Active",
"Active_users": "Active users",
"Activity": "Activity",
Expand Down Expand Up @@ -1844,7 +1844,7 @@
"Email_subject": "Email Subject",
"Email_verified": "Email verified",
"Email_sent": "Email sent",
"Email_verification_isnt_required": "Email verification is not required. Change this registration option in <a href=\"{{url}}\">accounts settings</a> to enable.",
"Email_verification_isnt_required": "Email verification to login is not required. To require, enable setting in <a href=\"{{url}}\">Accounts</a> > Registration",
"Emoji": "Emoji",
"Emoji_picker": "Emoji picker",
"EmojiCustomFilesystem": "Custom Emoji Filesystem",
Expand Down Expand Up @@ -3292,7 +3292,7 @@
"Managing_assets": "Managing assets",
"Managing_integrations": "Managing integrations",
"Manual_Selection": "Manual Selection",
"Manually_created_users_briefing": "Manually created users will initially be listed under the 'Pending' tab. Once they log in for the first time, they will be moved to the 'Active' tab.",
"Manually_created_users_briefing": "Manually created users will initially be shown as pending. Once they log in for the first time, they will be shown as active.",
"Manufacturing": "Manufacturing",
"MapView_Enabled": "Enable Mapview",
"MapView_Enabled_Description": "Enabling mapview will display a location share button on the right of the chat input field.",
Expand Down

0 comments on commit 48f3e33

Please sign in to comment.