[SG-599] Cannot read authenticator key if you don't include URI before TOTP Secret. (#2047)

Removed unnecessary code when adding a TOTP auth key secret manually
This commit is contained in:
André Filipe da Silva Bispo 2022-08-23 15:48:45 +01:00 committed by GitHub
parent ecd4da08ee
commit 9163b9e4de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -170,28 +170,11 @@ namespace Bit.App.Pages
private void AddAuthenticationKey_OnClicked(object sender, EventArgs e)
{
var text = ViewModel.TotpAuthenticationKey;
if (!string.IsNullOrWhiteSpace(text))
if (!string.IsNullOrWhiteSpace(ViewModel.TotpAuthenticationKey))
{
if (text.StartsWith("otpauth://totp"))
{
_callback(text);
_callback(ViewModel.TotpAuthenticationKey);
return;
}
else if (Uri.TryCreate(text, UriKind.Absolute, out Uri uri) &&
!string.IsNullOrWhiteSpace(uri?.Query))
{
var queryParts = uri.Query.Substring(1).ToLowerInvariant().Split('&');
foreach (var part in queryParts)
{
if (part.StartsWith("secret="))
{
_callback(part.Substring(7)?.ToUpperInvariant());
return;
}
}
}
}
_callback(null);
}