mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-10 04:22:13 +10:00
Progress on refactoring and abiding by cargo clippy
This commit is contained in:
@ -27,8 +27,9 @@ struct InitiateRequestBody {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
#[serde(rename_all="camelCase")]
|
||||||
struct HandshakeRequestBody {
|
struct HandshakeRequestBody {
|
||||||
clientId: String,
|
client_id: String,
|
||||||
token: String,
|
token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ pub fn generate_authorization_header() -> String {
|
|||||||
|
|
||||||
let signature = sign_nonce(certs.private, nonce.clone()).unwrap();
|
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<User, ()> {
|
pub fn fetch_user() -> Result<User, ()> {
|
||||||
@ -125,7 +126,7 @@ pub fn recieve_handshake(app: AppHandle, path: String) {
|
|||||||
let client_id = path_chunks.get(1).unwrap();
|
let client_id = path_chunks.get(1).unwrap();
|
||||||
let token = path_chunks.get(2).unwrap();
|
let token = path_chunks.get(2).unwrap();
|
||||||
let body = HandshakeRequestBody {
|
let body = HandshakeRequestBody {
|
||||||
clientId: client_id.to_string(),
|
client_id: client_id.to_string(),
|
||||||
token: token.to_string(),
|
token: token.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ pub fn recieve_handshake(app: AppHandle, path: String) {
|
|||||||
handle.auth = Some(DatabaseAuth {
|
handle.auth = Some(DatabaseAuth {
|
||||||
private: response_struct.private,
|
private: response_struct.private,
|
||||||
cert: response_struct.certificate,
|
cert: response_struct.certificate,
|
||||||
clientId: response_struct.id,
|
client_id: response_struct.id,
|
||||||
});
|
});
|
||||||
drop(handle);
|
drop(handle);
|
||||||
DB.save().unwrap();
|
DB.save().unwrap();
|
||||||
|
|||||||
@ -11,10 +11,11 @@ use serde::Deserialize;
|
|||||||
use crate::DB;
|
use crate::DB;
|
||||||
|
|
||||||
#[derive(serde::Serialize, Clone, Deserialize)]
|
#[derive(serde::Serialize, Clone, Deserialize)]
|
||||||
|
#[serde(rename_all="camelCase")]
|
||||||
pub struct DatabaseAuth {
|
pub struct DatabaseAuth {
|
||||||
pub private: String,
|
pub private: String,
|
||||||
pub cert: String,
|
pub cert: String,
|
||||||
pub clientId: String,
|
pub client_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize, Clone, Deserialize)]
|
#[derive(serde::Serialize, Clone, Deserialize)]
|
||||||
|
|||||||
@ -26,12 +26,13 @@ pub enum AppStatus {
|
|||||||
SignedInNeedsReauth,
|
SignedInNeedsReauth,
|
||||||
}
|
}
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all="camelCase")]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
id: String,
|
id: String,
|
||||||
username: String,
|
username: String,
|
||||||
admin: bool,
|
admin: bool,
|
||||||
displayName: String,
|
display_name: String,
|
||||||
profilePicture: String,
|
profile_picture: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize)]
|
#[derive(Clone, Serialize)]
|
||||||
@ -48,7 +49,7 @@ fn fetch_state<'a>(state: tauri::State<'_, Mutex<AppState>>) -> Result<AppState,
|
|||||||
Ok(cloned_state)
|
Ok(cloned_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup<'a>() -> AppState {
|
fn setup() -> AppState {
|
||||||
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||||
|
|
||||||
let is_set_up = db::is_set_up();
|
let is_set_up = db::is_set_up();
|
||||||
@ -119,9 +120,8 @@ pub fn run() {
|
|||||||
info!("handling drop:// url");
|
info!("handling drop:// url");
|
||||||
let binding = event.urls();
|
let binding = event.urls();
|
||||||
let url = binding.get(0).unwrap();
|
let url = binding.get(0).unwrap();
|
||||||
match url.host_str().unwrap() {
|
if url.host_str().unwrap() == "handshake" {
|
||||||
"handshake" => recieve_handshake(handle.clone(), url.path().to_string()),
|
recieve_handshake(handle.clone(), url.path().to_string())
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -26,8 +26,9 @@ macro_rules! unwrap_or_return {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
#[serde(rename_all="camelCase")]
|
||||||
struct DropHealthcheck {
|
struct DropHealthcheck {
|
||||||
appName: String,
|
app_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@ -44,7 +45,7 @@ pub async fn use_remote<'a>(
|
|||||||
|
|
||||||
let result = response.json::<DropHealthcheck>().await.unwrap();
|
let result = response.json::<DropHealthcheck>().await.unwrap();
|
||||||
|
|
||||||
if result.appName != "Drop" {
|
if result.app_name != "Drop" {
|
||||||
warn!("user entered drop endpoint that connected, but wasn't identified as Drop");
|
warn!("user entered drop endpoint that connected, but wasn't identified as Drop");
|
||||||
return Err("Not a valid Drop endpoint".to_string());
|
return Err("Not a valid Drop endpoint".to_string());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user