Skip to content

Commit

Permalink
Merge pull request #2496 from PhilippC/2458--seed-only-traytotp-style…
Browse files Browse the repository at this point in the history
…-entries

make settings field for TrayTotp style otp entries optional
  • Loading branch information
PhilippC authored Jan 3, 2024
2 parents 64355a3 + c934755 commit 49cb33a
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/keepass2android/Totp/TrayTotpPluginAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,8 @@ public TrayTotpHandler(Context ctx, Handler uiThreadHandler, bool muteWarnings)
_muteWarnings = muteWarnings;
}

/// <summary>
/// Check if specified Entry contains Settings that are not null.
/// </summary>
internal bool SettingsCheck(IDictionary<string, string> entryFields)
{
string settings;
entryFields.TryGetValue(SettingsFieldName, out settings);
return !String.IsNullOrEmpty(settings);
}

internal bool SeedCheck(IDictionary<string, string> entryFields)

internal bool HasSeed(IDictionary<string, string> entryFields)
{
string seed;
entryFields.TryGetValue(SeedFieldName, out seed);
Expand Down Expand Up @@ -100,15 +91,15 @@ internal bool SettingsValidate(IDictionary<string, string> entryFields, out bool
}

private string[] SettingsGet(IDictionary<string, string> entryFields)
{
return entryFields[SettingsFieldName].Split(';');
}
{
return entryFields.TryGetValue(SettingsFieldName, out var settings) ? settings.Split(';') : new[] { "30", "6" };
}

public TotpData GetTotpData(IDictionary<string, string> entryFields)
{
TotpData res = new TotpData();

if (SettingsCheck(entryFields) && SeedCheck(entryFields))
if (HasSeed(entryFields))
{
bool ValidInterval; bool ValidLength; bool ValidUrl;
if (SettingsValidate(entryFields, out ValidInterval, out ValidLength, out ValidUrl))
Expand Down

0 comments on commit 49cb33a

Please sign in to comment.