add credentials entry view

This commit is contained in:
jfmonty2 committed 2022-12-13 21:50:34 -08:00
1 parent 9055fa41aa
commit 67705aa2d1
6 files changed
+83 -33

No files matched your search

+13 -3
View File
@@ -1,7 +1,7 @@
use serde::{Serialize, Deserialize};
use tauri::State;
use crate::state::{AppState, Session};
use crate::state::{AppState, Session, Credentials};
#[derive(Clone, Serialize, Deserialize)]
@@ -43,8 +43,7 @@ pub fn respond(response: RequestResponse, app_state: State<'_, AppState>) -> Res
pub async fn unlock(passphrase: String, app_state: State<'_, AppState>) -> Result<(), String> {
app_state.decrypt(&passphrase)
.await
.map_err(|e| e.to_string())?;
Ok(())
.map_err(|e| e.to_string())
}
@@ -58,3 +57,14 @@ pub fn get_session_status(app_state: State<'_, AppState>) -> String {
}
}
#[tauri::command]
pub async fn save_credentials(
credentials: Credentials,
passphrase: String,
app_state: State<'_, AppState>
) -> Result<(), String> {
app_state.save_creds(credentials, &passphrase)
.await
.map_err(|e| e.to_string())
}