From 5d1c4a8c872274fb753468039cfed0d6c7dd0664 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sun, 19 Mar 2023 22:31:46 -0500 Subject: [PATCH] Passcode: Disable passcode when "Keep me signed in" is disabled (#2814) --- src/components/left/main/LeftMainHeader.tsx | 9 +++-- .../left/settings/SettingsPrivacy.tsx | 35 +++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/components/left/main/LeftMainHeader.tsx b/src/components/left/main/LeftMainHeader.tsx index 30c173d66..fae12aa9f 100644 --- a/src/components/left/main/LeftMainHeader.tsx +++ b/src/components/left/main/LeftMainHeader.tsx @@ -77,6 +77,7 @@ type StateProps = isConnectionStatusMinimized: ISettings['isConnectionStatusMinimized']; areChatsLoaded?: boolean; hasPasscode?: boolean; + isAuthRememberMe?: boolean; } & Pick & Pick; @@ -109,6 +110,7 @@ const LeftMainHeader: FC = ({ isConnectionStatusMinimized, areChatsLoaded, hasPasscode, + isAuthRememberMe, canInstall, archiveSettings, }) => { @@ -160,14 +162,14 @@ const LeftMainHeader: FC = ({ } else { requestNextSettingsScreen({ screen: SettingsScreens.PasscodeDisabled }); } - }, [hasPasscode, lockScreen, requestNextSettingsScreen]); + }, [hasPasscode]); - useHotkeys({ + useHotkeys(isAuthRememberMe ? { 'Ctrl+Shift+L': handleLockScreenHotkey, 'Alt+Shift+L': handleLockScreenHotkey, 'Meta+Shift+L': handleLockScreenHotkey, ...(IS_PWA && { 'Mod+L': handleLockScreenHotkey }), - }); + } : undefined); const withOtherVersions = window.location.hostname === PRODUCTION_HOSTNAME || IS_TEST; @@ -484,6 +486,7 @@ export default memo(withGlobal( hasPasscode: Boolean(global.passcode.hasPasscode), canInstall: Boolean(tabState.canInstall), archiveSettings, + isAuthRememberMe: global.authRememberMe, }; }, )(LeftMainHeader)); diff --git a/src/components/left/settings/SettingsPrivacy.tsx b/src/components/left/settings/SettingsPrivacy.tsx index a0b9b9256..95f5cbbe6 100644 --- a/src/components/left/settings/SettingsPrivacy.tsx +++ b/src/components/left/settings/SettingsPrivacy.tsx @@ -23,6 +23,7 @@ type StateProps = { isCurrentUserPremium?: boolean; hasPassword?: boolean; hasPasscode?: boolean; + isAuthRememberMe?: boolean; blockedCount: number; webAuthCount: number; isSensitiveEnabled?: boolean; @@ -62,6 +63,7 @@ const SettingsPrivacy: FC = ({ privacyPhoneP2P, onScreenSelect, onReset, + isAuthRememberMe, }) => { const { loadPrivacySettings, @@ -158,21 +160,23 @@ const SettingsPrivacy: FC = ({ {lang('BlockedUsers')} {blockedCount || ''} - onScreenSelect( - hasPasscode ? SettingsScreens.PasscodeEnabled : SettingsScreens.PasscodeDisabled, - )} - > -
- {lang('Passcode')} - - {lang(hasPasscode ? 'PasswordOn' : 'PasswordOff')} - -
-
+ {isAuthRememberMe && ( + onScreenSelect( + hasPasscode ? SettingsScreens.PasscodeEnabled : SettingsScreens.PasscodeDisabled, + )} + > +
+ {lang('Passcode')} + + {lang(hasPasscode ? 'PasswordOn' : 'PasswordOff')} + +
+
+ )} ( privacyPhoneCall: privacy.phoneCall, privacyPhoneP2P: privacy.phoneP2P, canDisplayChatInTitle, + isAuthRememberMe: global.authRememberMe, }; }, )(SettingsPrivacy));