Esempio n. 1
0
        public async Task <string> GetTotpAsync(CipherViewModel item)
        {
            string totp          = null;
            var    accessPremium = await _stateService.CanAccessPremiumAsync();

            if (accessPremium || (item?.CipherView.OrganizationUseTotp ?? false))
            {
                if (item != null && !string.IsNullOrWhiteSpace(item.Totp))
                {
                    totp = await _totpService.GetCodeAsync(item.Totp);
                }
            }
            return(totp);
        }
Esempio n. 2
0
        private async Task CopyTotpAsync(CipherView cipher)
        {
            if (!string.IsNullOrWhiteSpace(cipher?.Login?.Totp))
            {
                var autoCopyDisabled = await _stateService.GetDisableAutoTotpCopyAsync();

                var canAccessPremium = await _stateService.CanAccessPremiumAsync();

                if ((canAccessPremium || cipher.OrganizationUseTotp) && !autoCopyDisabled.GetValueOrDefault())
                {
                    var totpService = ServiceContainer.Resolve <ITotpService>("totpService");
                    var totp        = await totpService.GetCodeAsync(cipher.Login.Totp);

                    if (totp != null)
                    {
                        CopyToClipboard(totp);
                    }
                }
            }
        }