add button to disable ISync

This commit is contained in:
Mystikfluu 2023-04-04 15:26:09 +02:00
parent c09e478ffd
commit 0085866268
2 changed files with 13 additions and 2 deletions

View File

@ -84,6 +84,13 @@ fn store_token(token: String) {
file.write_all(token.as_bytes()).unwrap();
}
#[tauri::command]
fn remove_token() {
let filepath = &(ip_lib::get_ipass_folder()+"token.ipasst");
std::fs::remove_file(filepath).unwrap();
//TODO: cleaner solution via IPass api call to unauthorize
}
#[tauri::command]
fn get_isync_status() -> bool {
let filepath = &(ip_lib::get_ipass_folder()+"token.ipasst");
@ -117,7 +124,7 @@ fn main() {
get_version,create_entry,random_password,
get_entry,get_entries,remove_entry,
open_authorize,store_token,get_isync_status,
sync_isync])
sync_isync,remove_token])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -13,7 +13,7 @@
<h2>ISync</h2>
<h4>Keep your passwords up-to-date on multiple devices</h4>
<span>Current status: <b id="ISyncStatus">Checking</b></span>
<a href="/enableISync.html" class="nostyle" id="enableISync">Enable ISync</a>
<button id="enableISyncButton"><a href="/enableISync.html" class="nostyle" id="enableISync">Enable ISync</a></button>
</div>
<script>
const { invoke } = window.__TAURI__.tauri;
@ -21,7 +21,11 @@
let status = await invoke("get_isync_status")
document.getElementById("ISyncStatus").innerText=status?"Enabled":"Disabled"
if(status){
document.getElementById("enableISyncButton").innerText="Disable ISync"
document.getElementById("enableISync").remove()
document.getElementById("enableISyncButton").addEventListener("onclick",(_e)=>{
invoke("remove_token")
})
}
}
start()