Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: security tab visibility #31996

Merged
merged 14 commits into from
Apr 17, 2024
5 changes: 5 additions & 0 deletions .changeset/afraid-poets-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixing Security tab visibility to allow password changes when 2FA/E2E is disabled.
abhinavkrin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ const AccountSecurityPage = (): ReactElement => {
const twoFactorTOTP = useSetting('Accounts_TwoFactorAuthentication_By_TOTP_Enabled');
const twoFactorByEmailEnabled = useSetting('Accounts_TwoFactorAuthentication_By_Email_Enabled');
const e2eEnabled = useSetting('E2E_Enable');
const allowPasswordChange = useSetting('Accounts_AllowPasswordChange');

const passwordFormId = useUniqueId();

if (!twoFactorEnabled && !e2eEnabled) {
if (!twoFactorEnabled && !e2eEnabled && !allowPasswordChange) {
abhinavkrin marked this conversation as resolved.
Show resolved Hide resolved
return <NotAuthorizedPage />;
}

Expand All @@ -42,13 +43,15 @@ const AccountSecurityPage = (): ReactElement => {
<PageHeader title={t('Security')} />
<PageScrollableContentWithShadow>
<Box maxWidth='x600' w='full' alignSelf='center' color='default'>
<FormProvider {...methods}>
<Accordion>
<Accordion.Item title={t('Password')} defaultExpanded>
<ChangePassword id={passwordFormId} />
</Accordion.Item>
</Accordion>
</FormProvider>
{allowPasswordChange && (
<FormProvider {...methods}>
<Accordion>
<Accordion.Item title={t('Password')} defaultExpanded>
<ChangePassword id={passwordFormId} />
</Accordion.Item>
</Accordion>
</FormProvider>
)}
<Accordion>
{(twoFactorTOTP || twoFactorByEmailEnabled) && twoFactorEnabled && (
<Accordion.Item title={t('Two Factor Authentication')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import AccountSecurityPage from './AccountSecurityPage';
const AccountSecurityRoute = (): ReactElement => {
const isTwoFactorEnabled = useSetting('Accounts_TwoFactorAuthentication_Enabled');
const isE2EEnabled = useSetting('E2E_Enable');
const canViewSecurity = isTwoFactorEnabled || isE2EEnabled;
const allowPasswordChange = useSetting('Accounts_AllowPasswordChange');

const canViewSecurity = isTwoFactorEnabled || isE2EEnabled || allowPasswordChange;

if (!canViewSecurity) {
return <NotAuthorizedPage />;
Expand Down
5 changes: 4 additions & 1 deletion apps/meteor/client/views/account/sidebarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export const {
href: '/account/security',
i18nLabel: 'Security',
icon: 'lock',
permissionGranted: (): boolean => settings.get('Accounts_TwoFactorAuthentication_Enabled') || settings.get('E2E_Enable'),
permissionGranted: (): boolean =>
settings.get('Accounts_TwoFactorAuthentication_Enabled') ||
settings.get('E2E_Enable') ||
settings.get('Accounts_AllowPasswordChange'),
},
{
href: '/account/integrations',
Expand Down
Loading