feat(lastfm): improve auth flow with embedded credentials support
- Add support for build-time credentials via LASTFM_API_KEY/LASTFM_API_SECRET env vars - Add lastfm_has_embedded_credentials command to check for embedded keys - Add lastfm_open_auth_url command to open browser via native opener - Simplify UI flow: if embedded credentials exist, just click Connect - Add cancel button during authorization flow - Clean up UI when waiting for user to authorize in browser
This commit is contained in:
1 parent
480594c03c
commit
19bad7200b
5 files changed
+112
-49
No files matched your search
@@ -2,16 +2,28 @@
|
||||
|
||||
use tauri::State;
|
||||
|
||||
use crate::lastfm::LastFmSession;
|
||||
use crate::lastfm::{LastFmClient, LastFmSession};
|
||||
use crate::AppState;
|
||||
|
||||
/// Check if Last.fm has API credentials configured
|
||||
/// Check if Last.fm has embedded (build-time) credentials
|
||||
#[tauri::command]
|
||||
pub fn lastfm_has_embedded_credentials() -> bool {
|
||||
LastFmClient::has_embedded_credentials()
|
||||
}
|
||||
|
||||
/// Check if Last.fm has API credentials configured (embedded or user-provided)
|
||||
#[tauri::command]
|
||||
pub async fn lastfm_has_credentials(state: State<'_, AppState>) -> Result<bool, String> {
|
||||
let client = state.lastfm.lock().await;
|
||||
Ok(client.has_credentials())
|
||||
}
|
||||
|
||||
/// Open a URL in the default browser
|
||||
#[tauri::command]
|
||||
pub async fn lastfm_open_auth_url(url: String) -> Result<(), String> {
|
||||
open::that(&url).map_err(|e| format!("Failed to open browser: {}", e))
|
||||
}
|
||||
|
||||
/// Set Last.fm API credentials
|
||||
#[tauri::command]
|
||||
pub async fn lastfm_set_credentials(
|
||||
|
||||
Reference in new issue
Block a user