mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-05 16:49:06 +00:00
Cannot delete some providers (#56)
Fixed the bug where users cannot delete a self-hosted provider when an API token was never entered
This commit is contained in:
parent
f3aa38e090
commit
cac2373269
@ -73,9 +73,10 @@ public sealed class SettingsManager
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Data structure for deleting a secret response.
|
/// Data structure for deleting a secret response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Success">True, when the secret was successfully deleted.</param>
|
/// <param name="Success">True, when the secret was successfully deleted or not found.</param>
|
||||||
/// <param name="Issue">The issue, when the secret could not be deleted.</param>
|
/// <param name="Issue">The issue, when the secret could not be deleted.</param>
|
||||||
public readonly record struct DeleteSecretResponse(bool Success, string Issue);
|
/// <param name="WasEntryFound">True, when the entry was found and deleted.</param>
|
||||||
|
public readonly record struct DeleteSecretResponse(bool Success, string Issue, bool WasEntryFound);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to delete the API key for the given provider.
|
/// Tries to delete the API key for the given provider.
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
- Improved readability of the issue component
|
- Improved readability of the issue component
|
||||||
- Improved switches: when an option is enabled, the switch is using a different color
|
- Improved switches: when an option is enabled, the switch is using a different color
|
||||||
- Fixed the applying of spellchecking settings to the single-line dialog
|
- Fixed the applying of spellchecking settings to the single-line dialog
|
||||||
|
- Fixed the bug where users cannot delete a self-hosted provider when an API token was never entered
|
||||||
- Restructured the layout of the settings page
|
- Restructured the layout of the settings page
|
||||||
- Refactored the settings data model
|
- Refactored the settings data model
|
||||||
- Upgraded to Rust 1.80.0
|
- Upgraded to Rust 1.80.0
|
||||||
|
@ -15,6 +15,7 @@ use tauri::api::process::{Command, CommandChild, CommandEvent};
|
|||||||
use tauri::utils::config::AppUrl;
|
use tauri::utils::config::AppUrl;
|
||||||
use tokio::time;
|
use tokio::time;
|
||||||
use flexi_logger::{AdaptiveFormat, Logger};
|
use flexi_logger::{AdaptiveFormat, Logger};
|
||||||
|
use keyring::error::Error::NoEntry;
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use tauri::updater::UpdateResponse;
|
use tauri::updater::UpdateResponse;
|
||||||
|
|
||||||
@ -454,19 +455,31 @@ fn delete_secret(destination: String, user_name: String) -> DeleteSecretResponse
|
|||||||
let service = format!("mindwork-ai-studio::{}", destination);
|
let service = format!("mindwork-ai-studio::{}", destination);
|
||||||
let entry = Entry::new(service.as_str(), user_name.as_str()).unwrap();
|
let entry = Entry::new(service.as_str(), user_name.as_str()).unwrap();
|
||||||
let result = entry.delete_password();
|
let result = entry.delete_password();
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
warn!("Secret for {service} and user {user_name} was deleted successfully.");
|
warn!("Secret for {service} and user {user_name} was deleted successfully.");
|
||||||
DeleteSecretResponse {
|
DeleteSecretResponse {
|
||||||
success: true,
|
success: true,
|
||||||
|
was_entry_found: true,
|
||||||
issue: String::from(""),
|
issue: String::from(""),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Err(NoEntry) => {
|
||||||
|
warn!("No secret for {service} and user {user_name} was found.");
|
||||||
|
DeleteSecretResponse {
|
||||||
|
success: true,
|
||||||
|
was_entry_found: false,
|
||||||
|
issue: String::from(""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to delete secret for {service} and user {user_name}: {e}.");
|
error!("Failed to delete secret for {service} and user {user_name}: {e}.");
|
||||||
DeleteSecretResponse {
|
DeleteSecretResponse {
|
||||||
success: false,
|
success: false,
|
||||||
|
was_entry_found: false,
|
||||||
issue: e.to_string(),
|
issue: e.to_string(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -476,6 +489,7 @@ fn delete_secret(destination: String, user_name: String) -> DeleteSecretResponse
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct DeleteSecretResponse {
|
struct DeleteSecretResponse {
|
||||||
success: bool,
|
success: bool,
|
||||||
|
was_entry_found: bool,
|
||||||
issue: String,
|
issue: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user