diff --git a/desktop/src-tauri/src/auth.rs b/desktop/src-tauri/src/auth.rs index 153161e9..99ab8ff8 100644 --- a/desktop/src-tauri/src/auth.rs +++ b/desktop/src-tauri/src/auth.rs @@ -27,8 +27,9 @@ struct InitiateRequestBody { } #[derive(Serialize)] +#[serde(rename_all="camelCase")] struct HandshakeRequestBody { - clientId: String, + client_id: String, token: String, } @@ -78,7 +79,7 @@ pub fn generate_authorization_header() -> String { let signature = sign_nonce(certs.private, nonce.clone()).unwrap(); - return format!("Nonce {} {} {}", certs.clientId, nonce, signature); + return format!("Nonce {} {} {}", certs.client_id, nonce, signature); } pub fn fetch_user() -> Result { @@ -125,7 +126,7 @@ pub fn recieve_handshake(app: AppHandle, path: String) { let client_id = path_chunks.get(1).unwrap(); let token = path_chunks.get(2).unwrap(); let body = HandshakeRequestBody { - clientId: client_id.to_string(), + client_id: client_id.to_string(), token: token.to_string(), }; @@ -140,7 +141,7 @@ pub fn recieve_handshake(app: AppHandle, path: String) { handle.auth = Some(DatabaseAuth { private: response_struct.private, cert: response_struct.certificate, - clientId: response_struct.id, + client_id: response_struct.id, }); drop(handle); DB.save().unwrap(); diff --git a/desktop/src-tauri/src/db.rs b/desktop/src-tauri/src/db.rs index 4683f849..4ee70f8d 100644 --- a/desktop/src-tauri/src/db.rs +++ b/desktop/src-tauri/src/db.rs @@ -11,10 +11,11 @@ use serde::Deserialize; use crate::DB; #[derive(serde::Serialize, Clone, Deserialize)] +#[serde(rename_all="camelCase")] pub struct DatabaseAuth { pub private: String, pub cert: String, - pub clientId: String, + pub client_id: String, } #[derive(serde::Serialize, Clone, Deserialize)] diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs index 3cc76169..04529818 100644 --- a/desktop/src-tauri/src/lib.rs +++ b/desktop/src-tauri/src/lib.rs @@ -26,12 +26,13 @@ pub enum AppStatus { SignedInNeedsReauth, } #[derive(Clone, Serialize, Deserialize)] +#[serde(rename_all="camelCase")] pub struct User { id: String, username: String, admin: bool, - displayName: String, - profilePicture: String, + display_name: String, + profile_picture: String, } #[derive(Clone, Serialize)] @@ -48,7 +49,7 @@ fn fetch_state<'a>(state: tauri::State<'_, Mutex>) -> Result() -> AppState { +fn setup() -> AppState { env_logger::Builder::from_env(Env::default().default_filter_or("info")).init(); let is_set_up = db::is_set_up(); @@ -119,9 +120,8 @@ pub fn run() { info!("handling drop:// url"); let binding = event.urls(); let url = binding.get(0).unwrap(); - match url.host_str().unwrap() { - "handshake" => recieve_handshake(handle.clone(), url.path().to_string()), - _ => (), + if url.host_str().unwrap() == "handshake" { + recieve_handshake(handle.clone(), url.path().to_string()) } }); diff --git a/desktop/src-tauri/src/remote.rs b/desktop/src-tauri/src/remote.rs index 431b7717..17efa118 100644 --- a/desktop/src-tauri/src/remote.rs +++ b/desktop/src-tauri/src/remote.rs @@ -26,8 +26,9 @@ macro_rules! unwrap_or_return { } #[derive(Deserialize)] +#[serde(rename_all="camelCase")] struct DropHealthcheck { - appName: String, + app_name: String, } #[tauri::command] @@ -44,7 +45,7 @@ pub async fn use_remote<'a>( let result = response.json::().await.unwrap(); - if result.appName != "Drop" { + if result.app_name != "Drop" { warn!("user entered drop endpoint that connected, but wasn't identified as Drop"); return Err("Not a valid Drop endpoint".to_string()); }