From d37b20725758154d17d4285f20f082ba09b5a8db Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 28 Dec 2025 06:36:42 +0000 Subject: [PATCH 1/2] feat: Improve login button visibility and authentication UX in upload dialog Changes made: - Disable Upload button when not authenticated (forces user to login first) - Improve status messages to clearly direct users to the Login button - Add authentication check at start of upload process with helpful error message - Update button enable/disable logic to require both authentication and directory selection - Make authentication status more prominent and clear This ensures users cannot miss the Login button and understand they must authenticate before uploading. --- Intersect.Editor/Forms/FrmUploadToServer.cs | 27 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Intersect.Editor/Forms/FrmUploadToServer.cs b/Intersect.Editor/Forms/FrmUploadToServer.cs index 09c9c73037..70c3bb8a35 100644 --- a/Intersect.Editor/Forms/FrmUploadToServer.cs +++ b/Intersect.Editor/Forms/FrmUploadToServer.cs @@ -63,7 +63,7 @@ private void LoadSettings() { _selectedDirectory = savedDirectory; txtDirectory.Text = savedDirectory; - btnUpload.Enabled = true; + // Don't enable upload here - let UpdateAuthenticationStatus handle it } var rawTokenResponse = Preferences.LoadPreference(nameof(TokenResponse)); @@ -93,13 +93,17 @@ private void UpdateAuthenticationStatus() if (_tokenResponse != null) { - lblStatus.Text = "✓ Authenticated"; + lblStatus.Text = "✓ Authenticated - Ready to upload"; btnLogin.Text = "Re-Login"; + // Only enable upload if we have authentication AND a directory selected + btnUpload.Enabled = !string.IsNullOrWhiteSpace(_selectedDirectory) && Directory.Exists(_selectedDirectory); } else { - lblStatus.Text = "⚠ Not authenticated - click Login to authenticate"; + lblStatus.Text = "⚠ Not authenticated - Please click the Login button below to authenticate"; btnLogin.Text = "Login"; + // Disable upload when not authenticated + btnUpload.Enabled = false; } // Login button is always visible now @@ -108,6 +112,7 @@ private void UpdateAuthenticationStatus() // Force UI refresh btnLogin.Refresh(); lblStatus.Refresh(); + btnUpload.Refresh(); } private bool IsTokenExpired(TokenResponse token) @@ -330,12 +335,26 @@ private void btnBrowse_Click(object sender, EventArgs e) { _selectedDirectory = folderDialog.SelectedPath; txtDirectory.Text = _selectedDirectory; - btnUpload.Enabled = true; + // Only enable upload if authenticated + btnUpload.Enabled = _tokenResponse != null && !IsTokenExpired(_tokenResponse); } } private async void btnUpload_Click(object sender, EventArgs e) { + // Check authentication first + if (_tokenResponse == null || IsTokenExpired(_tokenResponse)) + { + DarkMessageBox.ShowError( + "You must login before uploading.\n\nPlease click the 'Login' button below to authenticate.", + "Authentication Required", + DarkDialogButton.Ok, + Icon + ); + UpdateAuthenticationStatus(); + return; + } + if (string.IsNullOrWhiteSpace(txtServerUrl.Text)) { DarkMessageBox.ShowError( From fcdd4ce8d4fb30e555de45a61a0a60d3b2c6b0cd Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 28 Dec 2025 06:45:04 +0000 Subject: [PATCH 2/2] fix: Add defensive authentication check before upload - Add explicit null check for token and AccessToken before starting upload - Ensures upload fails fast with clear error if authentication is missing - Prevents potential null reference exceptions - Improves error messaging for authentication failures This provides an additional safety layer beyond the UI validation. --- Intersect.Editor/Forms/FrmUploadToServer.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Intersect.Editor/Forms/FrmUploadToServer.cs b/Intersect.Editor/Forms/FrmUploadToServer.cs index 70c3bb8a35..976ddc1bf1 100644 --- a/Intersect.Editor/Forms/FrmUploadToServer.cs +++ b/Intersect.Editor/Forms/FrmUploadToServer.cs @@ -718,12 +718,17 @@ private async Task PerformUpload() Timeout = TimeSpan.FromMinutes(30) }; - if (_tokenResponse != null) + // Double-check authentication before starting upload + if (_tokenResponse == null || string.IsNullOrWhiteSpace(_tokenResponse.AccessToken)) { - httpClient.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", _tokenResponse.AccessToken); + throw new Exception( + "Cannot upload without authentication. Please login first." + ); } + httpClient.DefaultRequestHeaders.Authorization = + new AuthenticationHeaderValue("Bearer", _tokenResponse.AccessToken); + const int batchSize = 10; const int maxRetries = 3;