protected override async void OK() { AuthenticationError = null; if (Equals(AuthenticationCTS, null)) { AuthenticationCTS = new CancellationTokenSource(); } else if (AuthenticationCTS.Token.CanBeCanceled) { AuthenticationCTS.Cancel(); } if (AuthenticationCTS.Token.IsCancellationRequested) { await Task.Run(() => AuthenticationCTS.Token.WaitHandle.WaitOne(TimeSpan.FromSeconds(5))); AuthenticationCTS = new CancellationTokenSource(); } Func <NetworkCredential, CancellationToken, IProgress <Int32>, Boolean> Authenticate = Extension.Authenticate; String Username = AuthenticationUsername; SecureString Password = AuthenticationPassword.SecurePassword; Boolean RememberMe = AuthenticationRememberMe; Boolean authenticationSuccess = await Task.Run(() => Authenticate(new NetworkCredential(Username, Password), AuthenticationCTS.Token, AuthenticationProgressReporter)); // Lookup UserPluginAuthenticationObject and remove it. String PluginName = Extension.ExtensionDescriptionAttribute.Name, PluginLanguage = Extension.ExtensionDescriptionAttribute.Language; UserPluginAuthenticationObject UserPluginAuthentication = App.CORE.UserAuthentication.UserPluginAuthentications.FirstOrDefault(_ => Equals(_.PluginName, PluginName) && Equals(_.PluginLanguage, PluginLanguage)); App.CORE.UserAuthentication.UserPluginAuthentications.Remove(UserPluginAuthentication); if (authenticationSuccess) { if (AuthenticationRememberMe) { UserPluginAuthentication = UserPluginAuthentication ?? new UserPluginAuthenticationObject(); UserPluginAuthentication.PluginName = PluginName; UserPluginAuthentication.PluginLanguage = PluginLanguage; UserPluginAuthentication.Username = Username; UserPluginAuthentication.Password = Password; App.CORE.UserAuthentication.UserPluginAuthentications.Add(UserPluginAuthentication); } Extension = null; base.OK(); } else { AuthenticationError = "Unable to Authenticate User!"; AuthenticationUsername = String.Empty; if (!Equals(AuthenticationPassword, null)) { try { AuthenticationPassword.Clear(); } catch { } } ResetAuthenticationRememberMe(); } App.SaveUserAuthentication(); }
void ReleaseDesignerOutlets() { if (authenticationEmail != null) { authenticationEmail.Dispose(); authenticationEmail = null; } if (AuthenticationLoggedInUserDescription != null) { AuthenticationLoggedInUserDescription.Dispose(); AuthenticationLoggedInUserDescription = null; } if (AuthenticationPassword != null) { AuthenticationPassword.Dispose(); AuthenticationPassword = null; } if (LoginButton != null) { LoginButton.Dispose(); LoginButton = null; } if (LogoutButton != null) { LogoutButton.Dispose(); LogoutButton = null; } if (RegisterButton != null) { RegisterButton.Dispose(); RegisterButton = null; } }