Passcode: Disable passcode when "Keep me signed in" is disabled (#2814)

This commit is contained in:
Alexander Zinchuk 2023-03-19 22:31:46 -05:00
parent 97731fb30d
commit 5d1c4a8c87
2 changed files with 26 additions and 18 deletions

View File

@ -77,6 +77,7 @@ type StateProps =
isConnectionStatusMinimized: ISettings['isConnectionStatusMinimized']; isConnectionStatusMinimized: ISettings['isConnectionStatusMinimized'];
areChatsLoaded?: boolean; areChatsLoaded?: boolean;
hasPasscode?: boolean; hasPasscode?: boolean;
isAuthRememberMe?: boolean;
} }
& Pick<GlobalState, 'connectionState' | 'isSyncing' | 'archiveSettings'> & Pick<TabState, 'canInstall'>; & Pick<GlobalState, 'connectionState' | 'isSyncing' | 'archiveSettings'> & Pick<TabState, 'canInstall'>;
@ -109,6 +110,7 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
isConnectionStatusMinimized, isConnectionStatusMinimized,
areChatsLoaded, areChatsLoaded,
hasPasscode, hasPasscode,
isAuthRememberMe,
canInstall, canInstall,
archiveSettings, archiveSettings,
}) => { }) => {
@ -160,14 +162,14 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
} else { } else {
requestNextSettingsScreen({ screen: SettingsScreens.PasscodeDisabled }); requestNextSettingsScreen({ screen: SettingsScreens.PasscodeDisabled });
} }
}, [hasPasscode, lockScreen, requestNextSettingsScreen]); }, [hasPasscode]);
useHotkeys({ useHotkeys(isAuthRememberMe ? {
'Ctrl+Shift+L': handleLockScreenHotkey, 'Ctrl+Shift+L': handleLockScreenHotkey,
'Alt+Shift+L': handleLockScreenHotkey, 'Alt+Shift+L': handleLockScreenHotkey,
'Meta+Shift+L': handleLockScreenHotkey, 'Meta+Shift+L': handleLockScreenHotkey,
...(IS_PWA && { 'Mod+L': handleLockScreenHotkey }), ...(IS_PWA && { 'Mod+L': handleLockScreenHotkey }),
}); } : undefined);
const withOtherVersions = window.location.hostname === PRODUCTION_HOSTNAME || IS_TEST; const withOtherVersions = window.location.hostname === PRODUCTION_HOSTNAME || IS_TEST;
@ -484,6 +486,7 @@ export default memo(withGlobal<OwnProps>(
hasPasscode: Boolean(global.passcode.hasPasscode), hasPasscode: Boolean(global.passcode.hasPasscode),
canInstall: Boolean(tabState.canInstall), canInstall: Boolean(tabState.canInstall),
archiveSettings, archiveSettings,
isAuthRememberMe: global.authRememberMe,
}; };
}, },
)(LeftMainHeader)); )(LeftMainHeader));

View File

@ -23,6 +23,7 @@ type StateProps = {
isCurrentUserPremium?: boolean; isCurrentUserPremium?: boolean;
hasPassword?: boolean; hasPassword?: boolean;
hasPasscode?: boolean; hasPasscode?: boolean;
isAuthRememberMe?: boolean;
blockedCount: number; blockedCount: number;
webAuthCount: number; webAuthCount: number;
isSensitiveEnabled?: boolean; isSensitiveEnabled?: boolean;
@ -62,6 +63,7 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
privacyPhoneP2P, privacyPhoneP2P,
onScreenSelect, onScreenSelect,
onReset, onReset,
isAuthRememberMe,
}) => { }) => {
const { const {
loadPrivacySettings, loadPrivacySettings,
@ -158,21 +160,23 @@ const SettingsPrivacy: FC<OwnProps & StateProps> = ({
{lang('BlockedUsers')} {lang('BlockedUsers')}
<span className="settings-item__current-value">{blockedCount || ''}</span> <span className="settings-item__current-value">{blockedCount || ''}</span>
</ListItem> </ListItem>
<ListItem {isAuthRememberMe && (
icon="key" <ListItem
narrow icon="key"
// eslint-disable-next-line react/jsx-no-bind narrow
onClick={() => onScreenSelect( // eslint-disable-next-line react/jsx-no-bind
hasPasscode ? SettingsScreens.PasscodeEnabled : SettingsScreens.PasscodeDisabled, onClick={() => onScreenSelect(
)} hasPasscode ? SettingsScreens.PasscodeEnabled : SettingsScreens.PasscodeDisabled,
> )}
<div className="multiline-menu-item"> >
<span className="title">{lang('Passcode')}</span> <div className="multiline-menu-item">
<span className="subtitle" dir="auto"> <span className="title">{lang('Passcode')}</span>
{lang(hasPasscode ? 'PasswordOn' : 'PasswordOff')} <span className="subtitle" dir="auto">
</span> {lang(hasPasscode ? 'PasswordOn' : 'PasswordOff')}
</div> </span>
</ListItem> </div>
</ListItem>
)}
<ListItem <ListItem
icon="lock" icon="lock"
narrow narrow
@ -390,6 +394,7 @@ export default memo(withGlobal<OwnProps>(
privacyPhoneCall: privacy.phoneCall, privacyPhoneCall: privacy.phoneCall,
privacyPhoneP2P: privacy.phoneP2P, privacyPhoneP2P: privacy.phoneP2P,
canDisplayChatInTitle, canDisplayChatInTitle,
isAuthRememberMe: global.authRememberMe,
}; };
}, },
)(SettingsPrivacy)); )(SettingsPrivacy));