Add ability to deactivate license

This commit is contained in:
Gregory Schier
2025-03-05 07:13:19 -08:00
parent 9ead45d67a
commit 7a1a0689b0
16 changed files with 218 additions and 36 deletions
+18 -2
View File
@@ -1,5 +1,5 @@
use crate::errors::Result;
use crate::{activate_license, check_license, ActivateLicenseRequestPayload, LicenseCheckStatus};
use crate::{activate_license, check_license, deactivate_license, get_activation_id, ActivateLicenseRequestPayload, CheckActivationRequestPayload, DeactivateLicenseRequestPayload, LicenseCheckStatus};
use log::{debug, info};
use std::string::ToString;
use tauri::{command, AppHandle, Manager, Runtime, WebviewWindow};
@@ -7,7 +7,10 @@ use tauri::{command, AppHandle, Manager, Runtime, WebviewWindow};
#[command]
pub async fn check<R: Runtime>(app_handle: AppHandle<R>) -> Result<LicenseCheckStatus> {
debug!("Checking license");
check_license(&app_handle).await
check_license(&app_handle, CheckActivationRequestPayload{
app_platform: get_os().to_string(),
app_version: app_handle.package_info().version.to_string(),
}).await
}
#[command]
@@ -24,6 +27,19 @@ pub async fn activate<R: Runtime>(license_key: &str, window: WebviewWindow<R>) -
.await
}
#[command]
pub async fn deactivate<R: Runtime>(window: WebviewWindow<R>) -> Result<()> {
info!("Deactivating activation");
deactivate_license(
&window,
DeactivateLicenseRequestPayload {
app_platform: get_os().to_string(),
app_version: window.app_handle().package_info().version.to_string(),
},
)
.await
}
fn get_os() -> &'static str {
if cfg!(target_os = "windows") {
"windows"