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'];
areChatsLoaded?: boolean;
hasPasscode?: boolean;
isAuthRememberMe?: boolean;
}
& Pick<GlobalState, 'connectionState' | 'isSyncing' | 'archiveSettings'> & Pick<TabState, 'canInstall'>;
@ -109,6 +110,7 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
isConnectionStatusMinimized,
areChatsLoaded,
hasPasscode,
isAuthRememberMe,
canInstall,
archiveSettings,
}) => {
@ -160,14 +162,14 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
} 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<OwnProps>(
hasPasscode: Boolean(global.passcode.hasPasscode),
canInstall: Boolean(tabState.canInstall),
archiveSettings,
isAuthRememberMe: global.authRememberMe,
};
},
)(LeftMainHeader));

View File

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