diff --git a/DesktopEdge/MainWindow.xaml.cs b/DesktopEdge/MainWindow.xaml.cs index 8edd3329..29f3f782 100644 --- a/DesktopEdge/MainWindow.xaml.cs +++ b/DesktopEdge/MainWindow.xaml.cs @@ -132,6 +132,7 @@ namespace ZitiDesktopEdge { } else if (mfa.Action == "enrollment_remove") { // ShowBlurb("removed mfa: " + mfa.Successful, ""); } else if (mfa.Action == "mfa_auth_status") { + // serviceClient.GetStatusAsync(); // ShowBlurb("mfa authenticated: " + mfa.Successful, ""); } else { await ShowBlurbAsync ("Unexpected error when processing MFA", ""); @@ -263,9 +264,7 @@ namespace ZitiDesktopEdge { // and if someone pages the service list and we have not got an update from the service // this will also be invalid identities[i].IsTimingOut = false; - for (int j=0; j0) { + if (_timer != null) _timer.Stop(); + _timer = new System.Windows.Forms.Timer(); + _timer.Interval = _identity.MaxTimeout; + _timer.Tick += TimerTicked; + _timer.Start(); + } } else { ServiceCountArea.Visibility = Visibility.Collapsed; MfaRequired.Visibility = Visibility.Visible; @@ -73,6 +81,12 @@ namespace ZitiDesktopEdge { } } + private void TimerTicked(object sender, EventArgs e) { + _identity.MFAInfo.IsAuthenticated = false; + RefreshUI(); + _timer.Stop(); + } + public IdentityItem() { InitializeComponent(); ToggleSwitch.OnToggled += ToggleIdentity; diff --git a/DesktopEdge/Views/Screens/IdentityDetails.xaml.cs b/DesktopEdge/Views/Screens/IdentityDetails.xaml.cs index 25db0ab9..80c74d17 100644 --- a/DesktopEdge/Views/Screens/IdentityDetails.xaml.cs +++ b/DesktopEdge/Views/Screens/IdentityDetails.xaml.cs @@ -221,14 +221,22 @@ namespace ZitiDesktopEdge { try { if (_identity.IsMFAEnabled) { if (info.TimeoutRemaining > 0) { - TimeSpan t = TimeSpan.FromSeconds(info.TimeoutRemaining); + // t = TimeSpan.FromSeconds(info.TimeoutRemaining); + TimeSpan t = (DateTime.Now - info.TimeUpdated); + int timeout = info.Timeout - (int)Math.Floor(t.TotalSeconds); - string answer = string.Format("{0:D2} minutes", t.Minutes); - if (t.Days>0) answer = string.Format("{0:D2} days {1:D2} hours {2:D2} minutes", t.Days, t.Hours, t.Minutes); - else { - if (t.Hours>0) answer = string.Format("{0:D2} hours {1:D2} minutes", t.Hours, t.Minutes); + if (timeout>0) { + t = TimeSpan.FromSeconds(timeout); + string answer = string.Format("{0:D2} minutes", t.Minutes); + if (t.Days > 0) answer = string.Format("{0:D2} days {1:D2} hours {2:D2} minutes", t.Days, t.Hours, t.Minutes); + else { + if (t.Hours > 0) answer = string.Format("{0:D2} hours {1:D2} minutes", t.Hours, t.Minutes); + } + TimeoutDetails.Text = answer; + } else { + TimeoutDetails.Text = "Timed Out"; } - TimeoutDetails.Text = answer; + } else { TimeoutDetails.Text = "Timed Out"; } diff --git a/ZitiDesktopEdge.Client/DataStructures/DataStructures.cs b/ZitiDesktopEdge.Client/DataStructures/DataStructures.cs index aee92604..0bcb05f0 100644 --- a/ZitiDesktopEdge.Client/DataStructures/DataStructures.cs +++ b/ZitiDesktopEdge.Client/DataStructures/DataStructures.cs @@ -246,7 +246,7 @@ namespace ZitiDesktopEdge.DataStructures { public bool MfaNeeded { get; set; } public int MinTimeout { get; set; } public int MaxTimeout { get; set; } - public DateTime LastUpdatedTime { get; set; } + public DateTime MfaLastUpdatedTime { get; set; } } public class Service { @@ -332,8 +332,7 @@ namespace ZitiDesktopEdge.DataStructures { public string Message { get; set; } public int MfaMinimumTimeout { get; set; } public int MfaMaximumTimeout { get; set; } - public int TimeDuration { get; set; } - public int MfaTimeoutDuration { get; set; } + public int MfaTimeDuration { get; set; } public string Severity { get; set; } }