public async Task LockAsync(bool allowSoftLock = false, bool userInitiated = false)
        {
            var authed = await _userService.IsAuthenticatedAsync();

            if (!authed)
            {
                return;
            }
            if (allowSoftLock)
            {
                BiometricLocked = await IsBiometricLockSetAsync();

                if (BiometricLocked)
                {
                    _messagingService.Send("locked", userInitiated);
                    _lockedCallback?.Invoke(userInitiated);
                    return;
                }
            }
            await Task.WhenAll(
                _cryptoService.ClearKeyAsync(),
                _cryptoService.ClearOrgKeysAsync(true),
                _cryptoService.ClearKeyPairAsync(true),
                _cryptoService.ClearEncKeyAsync(true));

            _folderService.ClearCache();
            _cipherService.ClearCache();
            _collectionService.ClearCache();
            _searchService.ClearIndex();
            _messagingService.Send("locked", userInitiated);
            _lockedCallback?.Invoke(userInitiated);
        }
Пример #2
0
        private async Task TryClearCiphersCacheAsync()
        {
            if (Device.RuntimePlatform != Device.iOS)
            {
                return;
            }
            var clearCache = await _storageService.GetAsync <bool?>(Constants.ClearCiphersCacheKey);

            if (clearCache.GetValueOrDefault())
            {
                _cipherService.ClearCache();
                await _storageService.RemoveAsync(Constants.ClearCiphersCacheKey);
            }
        }
Пример #3
0
        public async Task LockAsync(bool allowSoftLock = false)
        {
            var authed = await _userService.IsAuthenticatedAsync();

            if (!authed)
            {
                return;
            }
            if (allowSoftLock)
            {
                var pinSet = await IsPinLockSetAsync();

                if (pinSet.Item1)
                {
                    PinLocked = true;
                }
                if (await IsFingerprintLockSetAsync())
                {
                    FingerprintLocked = true;
                }
                if (FingerprintLocked || PinLocked)
                {
                    _messagingService.Send("locked");
                    // TODO: locked callback?
                    return;
                }
            }
            await Task.WhenAll(
                _cryptoService.ClearKeyAsync(),
                _cryptoService.ClearOrgKeysAsync(true),
                _cryptoService.ClearKeyPairAsync(true),
                _cryptoService.ClearEncKeyAsync(true));

            _folderService.ClearCache();
            _cipherService.ClearCache();
            _collectionService.ClearCache();
            _searchService.ClearIndex();
            _messagingService.Send("locked");
            // TODO: locked callback?
        }