mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-10 04:22:13 +10:00
feat(auth): offer manual signin
This commit is contained in:
@ -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();
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user