diff --git a/components/InitiateAuthModule.vue b/components/InitiateAuthModule.vue index 5f7158c..1f9be6c 100644 --- a/components/InitiateAuthModule.vue +++ b/components/InitiateAuthModule.vue @@ -42,6 +42,31 @@ +
+

Having trouble?

+

+ You can manually enter the token from your web browser. +

+
+ + + Submit + +
+
+
@@ -101,6 +126,10 @@ import { invoke } from "@tauri-apps/api/core"; const loading = ref(false); const error = ref(); +const offerManual = ref(false); +const manualToken = ref(""); +const manualLoading = ref(false); + async function auth() { await invoke("auth_initiate"); } @@ -111,5 +140,23 @@ function authWrapper_wrapper() { loading.value = false; error.value = e; }); + setTimeout(() => { + offerManual.value = true; + }, 10000); +} + +async function continueManual() { + await invoke("manual_recieve_handshake", { token: manualToken.value }); +} + +function continueManual_wrapper() { + loading.value = true; + continueManual() + .catch((e) => { + error.value = e; + }) + .finally(() => { + loading.value = false; + }); } diff --git a/src-tauri/src/auth.rs b/src-tauri/src/auth.rs index 9d6afb5..24c8b57 100644 --- a/src-tauri/src/auth.rs +++ b/src-tauri/src/auth.rs @@ -1,7 +1,4 @@ -use std::{ - env, - sync::Mutex, -}; +use std::{env, sync::Mutex}; use chrono::Utc; use log::{info, warn}; @@ -138,6 +135,12 @@ fn recieve_handshake_logic(app: &AppHandle, path: String) -> Result<(), RemoteAc Ok(()) } +#[tauri::command] +pub fn manual_recieve_handshake(app: AppHandle, token: String) -> Result<(), String> { + recieve_handshake(app, format!("handshake/{}", token)); + Ok(()) +} + pub fn recieve_handshake(app: AppHandle, path: String) { // Tell the app we're processing app.emit("auth/processing", ()).unwrap(); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index b81130a..dfaa542 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -11,7 +11,7 @@ mod state; mod tests; use crate::db::DatabaseImpls; -use auth::{auth_initiate, generate_authorization_header, recieve_handshake, retry_connect}; +use auth::{auth_initiate, generate_authorization_header, manual_recieve_handshake, recieve_handshake, retry_connect}; use cleanup::{cleanup_and_exit, quit}; use db::{ add_download_dir, delete_download_dir, fetch_download_dir_stats, DatabaseInterface, GameStatus, @@ -213,6 +213,7 @@ pub fn run() { // Auth auth_initiate, retry_connect, + manual_recieve_handshake, // Remote use_remote, gen_drop_url, @@ -269,6 +270,7 @@ pub fn run() { info!("handling drop:// url"); let binding = event.urls(); let url = binding.first().unwrap(); + return; // We're macOS if url.host_str().unwrap() == "handshake" { recieve_handshake(handle.clone(), url.path().to_string()) } @@ -345,16 +347,20 @@ pub fn run() { responder.respond(resp); }) - .on_window_event(|window, event| if let WindowEvent::CloseRequested { api, .. } = event { - window.hide().unwrap(); - api.prevent_close(); + .on_window_event(|window, event| { + if let WindowEvent::CloseRequested { api, .. } = event { + window.hide().unwrap(); + api.prevent_close(); + } }) .build(tauri::generate_context!()) .expect("error while running tauri application"); - app.run(|app_handle, event| if let RunEvent::ExitRequested { code, api, .. } = event { - if code.is_none() { - api.prevent_exit(); + app.run(|app_handle, event| { + if let RunEvent::ExitRequested { code, api, .. } = event { + if code.is_none() { + api.prevent_exit(); + } } }); }